From VisualWorks®, 7.6 of February 1, 2008 on February 1, 2008 at 12:31:54 pm (Dialog confirm: 'You are filing-in a Parcel source file!\\While this is possible it will not have\the same effect as loading the parcel.\None of the Parcel''s prerequisites will\be loaded and none of its load actions\will be performed.\\Are you sure you want to file-in?' withCRs) ifFalse: [self error: 'Parcel file-in abandoned. Choose terminate or close.'] <name>X509</name> <environment>Security</environment> <private>false</private> <imports> private Smalltalk.* private ASN1.* private Security.* </imports> <category>X509</category> <attributes> <package>X509</package> </attributes> <class> <name>X509Exception</name> <environment>Security.X509</environment> <super>Core.Exception</super> <private>false</private> none <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.X509Exception
Abstract superclass of all X509 exceptions.
</comment> <class> <name>X509Error</name> <environment>Security.X509</environment> <super>Security.X509.X509Exception</super> <private>false</private> none <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.X509Error
Abstract superclass of all X509 errors. Note that X509 notifications are not considered errors.
</comment> <class> <name>X509Warning</name> <environment>Security.X509</environment> <super>Security.X509.X509Error</super> <private>false</private> none <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.X509Warning
X509 warnings all indicate serious security issues, but they still allow to proceed when explicitly resumed. This capability is often expected by the user in situations with significantly relaxed security requirements.
</comment> <class> <name>BadCertificate</name> <environment>Security.X509</environment> <super>Security.X509.X509Warning</super> <private>false</private> none <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.BadCertificate
Indicates that a certificate has structural errors.
</comment> <class> <name>RootNotTrusted</name> <environment>Security.X509</environment> <super>Security.X509.X509Warning</super> <private>false</private> none <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.RootNotTrusted
Indicates that the root certificate of a chain doesn't match any of the trusted certificates in a registry.
</comment> <class> <name>X509Object</name> <environment>Security.X509</environment> <super>Core.Object</super> <private>false</private> none <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.X509Object
Common superclass of all entities identified by the X509 standard.
</comment> <class> <name>Validity</name> <environment>Security.X509</environment> <super>Security.X509.X509Object</super> <private>false</private> none notBefore notAfter <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.Validity
RFC 3280 (section 4.1.2.5 Validity): The certificate validity period is the time interval during which the CA warrants that it will maintain information about the status of the certificate. The field is represented as a SEQUENCE of two dates: the date on which the certificate validity period begins (notBefore) and the date on which the certificate validity period ends (notAfter). Both notBefore and notAfter may be encoded as UTCTime or GeneralizedTime. CAs conforming to this profile MUST always encode certificate validity dates through the year 2049 as UTCTime; certificate validity dates in 2050 or later MUST be encoded as GeneralizedTime. The validity period for a certificate is the period of time from notBefore through notAfter, inclusive. 4.1.2.5.1 UTCTime The universal time type, UTCTime, is a standard ASN.1 type intended for representation of dates and time. UTCTime specifies the year through the two low order digits and time is specified to the precision of one minute or one second. UTCTime includes either Z (for Zulu, or Greenwich Mean Time) or a time differential. For the purposes of this profile, UTCTime values MUST be expressed Greenwich Mean Time (Zulu) and MUST include seconds (i.e., times are YYMMDDHHMMSSZ), even where the number of seconds is zero. Conforming systems MUST interpret the year field (YY) as follows: Where YY is greater than or equal to 50, the year SHALL be interpreted as 19YY; and Where YY is less than 50, the year SHALL be interpreted as 20YY. 4.1.2.5.2 GeneralizedTime The generalized time type, GeneralizedTime, is a standard ASN.1 type for variable precision representation of time. Optionally, the GeneralizedTime field can include a representation of the time differential between local and Greenwich Mean Time. For the purposes of this profile, GeneralizedTime values MUST be expressed Greenwich Mean Time (Zulu) and MUST include seconds (i.e., times are YYYYMMDDHHMMSSZ), even where the number of seconds is zero. GeneralizedTime values MUST NOT include fractional seconds. Instance Variables: notBefore <Asn1Choice> certificate is valid from; timestamp adjusted to reference timezone (TimeZone class>>reference) notAfter <Asn1Choice> certfificate is valid until; timestamp adjusted to reference timezone (TimeZone class>>reference)
</comment> <class> <name>BrokenChain</name> <environment>Security.X509</environment> <super>Security.X509.X509Warning</super> <private>false</private> none <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.BrokenChain
Indicates that a chain contains a certificate whose issuer doesn't match the succeeding certificate in the chain.
</comment> <class> <name>Extension</name> <environment>Security.X509</environment> <super>Security.X509.X509Object</super> <private>false</private> none oid critical value oid <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.Extension
RFC 3280 (section 4.2 Certificate Extensions): The extensions defined for X.509 v3 certificates provide methods for associating additional attributes with users or public keys and for managing a certification hierarchy. The X.509 v3 certificate format also allows communities to define private extensions to carry information unique to those communities. Each extension in a certificate is designated as either critical or non-critical. A certificate using system MUST reject the certificate if it encounters a critical extension it does not recognize; however, a non-critical extension MAY be ignored if it is not recognized. The following sections present recommended extensions used within Internet certificates and standard locations for information. Communities may elect to use additional extensions; however, caution ought to be exercised in adopting any critical extensions in certificates which might prevent use in a general context. Each extension includes an OID and an ASN.1 structure. When an extension appears in a certificate, the OID appears as the field extnID and the corresponding ASN.1 encoded structure is the value of the octet string extnValue. A certificate MUST NOT include more than one instance of a particular extension. For example, a certificate may contain only one authority key identifier extension (section 4.2.1.1). An extension includes the boolean critical, with a default value of FALSE. The text for each extension specifies the acceptable values for the critical field. Conforming CAs MUST support key identifiers (sections 4.2.1.1 and 4.2.1.2), basic constraints (section 4.2.1.10), key usage (section 4.2.1.3), and certificate policies (section 4.2.1.5) extensions. If the CA issues certificates with an empty sequence for the subject field, the CA MUST support the subject alternative name extension (section 4.2.1.7). Support for the remaining extensions is OPTIONAL. Conforming CAs MAY support extensions that are not identified within this specification; certificate issuers are cautioned that marking such extensions as critical may inhibit interoperability. At a minimum, applications conforming to this profile MUST recognize the following extensions: key usage (section 4.2.1.3), certificate policies (section 4.2.1.5), the subject alternative name (section 4.2.1.7), basic constraints (section 4.2.1.10), name constraints (section 4.2.1.11), policy constraints (section 4.2.1.12), extended key usage (section 4.2.1.13), and inhibit any-policy (section 4.2.1.15). In addition, applications conforming to this profile SHOULD recognize the authority and subject key identifier (sections 4.2.1.1 and 4.2.1.2), and policy mapping (section 4.2.1.6) extensions. Extension ::= SEQUENCE { extnID OBJECT IDENTIFIER, critical BOOLEAN DEFAULT FALSE, extnValue OCTET STRING } Instance Variables: oid <Asn1OID> OID indicating the specific type of extension critical <Boolean> indicates extensions that must be processed successfully to validate the containing certificates value <ByteArray> DER encoded extension specific content Class Instance Variables: oid <Asn1OID> caches the OID specific to the extension class
</comment> <class> <name>SubjectKeyIdentifier</name> <environment>Security.X509</environment> <super>Security.X509.Extension</super> <private>false</private> none identifier <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.SubjectKeyIdentifier
RFC 3280 (section 4.2.1.2 Subject Key Identifier): The subject key identifier extension provides a means of identifying certificates that contain a particular public key. To facilitate certification path construction, this extension MUST appear in all conforming CA certificates, that is, all certificates including the basic constraints extension (section 4.2.1.10) where the value of cA is TRUE. The value of the subject key identifier MUST be the value placed in the key identifier field of the Authority Key Identifier extension (section 4.2.1.1) of certificates issued by the subject of this certificate. For CA certificates, subject key identifiers SHOULD be derived from the public key or a method that generates unique values. Two common methods for generating key identifiers from the public key are: (1) The keyIdentifier is composed of the 160-bit SHA-1 hash of the value of the BIT STRING subjectPublicKey (excluding the tag, length, and number of unused bits). (2) The keyIdentifier is composed of a four bit type field with the value 0100 followed by the least significant 60 bits of the SHA-1 hash of the value of the BIT STRING subjectPublicKey (excluding the tag, length, and number of unused bit string bits). One common method for generating unique values is a monotonically increasing sequence of integers. For end entity certificates, the subject key identifier extension provides a means for identifying certificates containing the particular public key used in an application. Where an end entity has obtained multiple certificates, especially from multiple CAs, the subject key identifier provides a means to quickly identify the set of certificates containing a particular public key. To assist applications in identifying the appropriate end entity certificate, this extension SHOULD be included in all end entity certificates. For end entity certificates, subject key identifiers SHOULD be derived from the public key. Two common methods for generating key identifiers from the public key are identified above. Where a key identifier has not been previously established, this specification RECOMMENDS use of one of these methods for generating keyIdentifiers. Where a key identifier has been previously established, the CA SHOULD use the previously established identifier. This extension MUST NOT be marked critical. id-ce-subjectKeyIdentifier OBJECT IDENTIFIER ::= { id-ce 14 } SubjectKeyIdentifier ::= KeyIdentifier Instance Variables: identifier <ByteArray>
</comment> <class> <name>Name</name> <environment>Security.X509</environment> <super>Security.X509.X509Object</super> <private>false</private> none relativeDistinguishedName encoding <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.Name
Names are used to identify subject and issuer of a certificate. They are also used to construct valid certificate chains by matching the issuer name of a certificate to the subject name in a CA certificate (see below). RFC 3280 (section 4.1.2.4 Issuer): Non-empty distinguished name (DN) defined as X.501 type Name. Name is defined by the following ASN.1 structures: Name ::= CHOICE { RDNSequence } RDNSequence ::= SEQUENCE OF RelativeDistinguishedName RelativeDistinguishedName ::= SET OF AttributeTypeAndValue Certificate users MUST be prepared to process the issuer distinguished name and subject distinguished name (section 4.1.2.6) fields to perform name chaining for certification path validation (section 6). Name chaining is performed by matching the issuer distinguished name in one certificate with the subject name in a CA certificate. This specification requires only a subset of the name comparison functionality specified in the X.500 series of specifications. Conforming implementations are REQUIRED to implement the following name comparison rules: (a) attribute values encoded in different types (e.g., PrintableString and BMPString) MAY be assumed to represent different strings; (b) attribute values in types other than PrintableString are case sensitive (this permits matching of attribute values as binary objects); (c) attribute values in PrintableString are not case sensitive (e.g., "Marianne Swanson" is the same as "MARIANNE SWANSON"); and (d) attribute values in PrintableString are compared after removing leading and trailing white space and converting internal substrings of one or more consecutive white space characters to a single space. These name comparison rules permit a certificate user to validate certificates issued using languages or encodings unfamiliar to the certificate user. In addition, implementations of this specification MAY use these comparison rules to process unfamiliar attribute types for name chaining. This allows implementations to process certificates with unfamiliar attributes in the issuer name. Note that the comparison rules defined in the X.500 series of specifications indicate that the character sets used to encode data in distinguished names are irrelevant. The characters themselves are compared without regard to encoding. Implementations of this profile are permitted to use the comparison algorithm defined in the X.500 series. Such an implementation will recognize a superset of name matches recognized by the algorithm specified above. Instance Variables: relativeDistinguishedName <OrderedCollection of: X509AttributeValueAssertion> name elements encoding <Asn1Encoding> DER encoding of myself
</comment> <class> <name>X509Registry</name> <environment>Security.X509</environment> <super>Core.Object</super> <private>false</private> objects trustedCertificates revokedCertificates strict default <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.X509Registry
A registry maintains a set of trusted CA (certificate authority) certificates. It is used to validate certificate chains. Any chain with the root certificate from the trusted collection can be validated. There is a default registry instance (X509Registry class>>default) which gets initialized from a trustedCertifcates.pem file in the image directory (or remains empty if the file isn't present). Applications are free to use their own registries instead of the default one. Instance Variables: trustedCertificates <Set of: X509Certificate> collection of trusted root certificates revokedCertificates <Set of: X509Certificate> collection of certificates that were revoked and should be rejected strict <Boolean> adhere strictly to the latest version of the specification (RFC 3280 at the moment) Class Instance Variables: default <X509Registry> default instance of the registry Shared Class Variables: DefaultCertificateFile <String> the default trusted Certificate pem file ShouldBeStrict <Boolean> default 'strict' value for X509Registries
</comment> <class> <name>DSSParameters</name> <environment>Security.X509</environment> <super>Security.X509.X509Object</super> <private>false</private> none p q g <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.DSSParameters
The DSA algorithm may include optional domain parameters. These parameters are commonly referred to as p, q, and g. RFC 3279 (section 2.3.2 DSA Signature Keys): The Digital Signature Algorithm (DSA) is defined in the Digital Signature Standard (DSS) [FIPS 186]. The DSA OID supported by this profile is: id-dsa OBJECT IDENTIFIER ::= {iso(1) member-body(2) us(840) x9-57(10040) x9cm(4) 1 } The id-dsa algorithm syntax includes optional domain parameters. These parameters are commonly referred to as p, q, and g. When omitted, the parameters component MUST be omitted entirely. That is, the AlgorithmIdentifier MUST be a SEQUENCE of one component: the OBJECT IDENTIFIER id-dsa. If the DSA domain parameters are present in the subjectPublicKeyInfo AlgorithmIdentifier, the parameters are included using the following ASN.1 structure: Dss-Parms ::= SEQUENCE { p INTEGER, q INTEGER, g INTEGER } The AlgorithmIdentifier within subjectPublicKeyInfo is the only place within a certificate where the parameters may be used. If the DSA algorithm parameters are omitted from the subjectPublicKeyInfo AlgorithmIdentifier and the CA signed the subject certificate using DSA, then the certificate issuer's DSA parameters apply to the subject's DSA key. If the DSA domain parameters are omitted from the SubjectPublicKeyInfo AlgorithmIdentifier and the CA signed the subject certificate using a signature algorithm other than DSA, then the subject's DSA domain parameters are distributed by other means. If the subjectPublicKeyInfo AlgorithmIdentifier field omits the parameters component, the CA signed the subject with a signature algorithm other than DSA, and the subject's DSA parameters are not available through other means, then clients MUST reject the certificate. Instance Variables: p <Integer> q <Integer> g <Integer>
</comment> <class> <name>KeyUsage</name> <environment>Security.X509</environment> <super>Security.X509.Extension</super> <private>false</private> none bits <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.KeyUsage
RFC 3280 (section 4.2.1.3 Key Usage): The key usage extension defines the purpose (e.g., encipherment, signature, certificate signing) of the key contained in the certificate. The usage restriction might be employed when a key that could be used for more than one operation is to be restricted. For example, when an RSA key should be used only to verify signatures on objects other than public key certificates and CRLs, the digitalSignature and/or nonRepudiation bits would be asserted. Likewise, when an RSA key should be used only for key management, the keyEncipherment bit would be asserted. This extension MUST appear in certificates that contain public keys that are used to validate digital signatures on other public key certificates or CRLs. When this extension appears, it SHOULD be marked critical. id-ce-keyUsage OBJECT IDENTIFIER ::= { id-ce 15 } KeyUsage ::= BIT STRING { digitalSignature (0), nonRepudiation (1), keyEncipherment (2), dataEncipherment (3), keyAgreement (4), keyCertSign (5), cRLSign (6), encipherOnly (7), decipherOnly (8) } Bits in the KeyUsage type are used as follows: The digitalSignature bit is asserted when the subject public key is used with a digital signature mechanism to support security services other than certificate signing (bit 5), or CRL signing (bit 6). Digital signature mechanisms are often used for entity authentication and data origin authentication with integrity. The nonRepudiation bit is asserted when the subject public key is used to verify digital signatures used to provide a non-repudiation service which protects against the signing entity falsely denying some action, excluding certificate or CRL signing. In the case of later conflict, a reliable third party may determine the authenticity of the signed data. Further distinctions between the digitalSignature and nonRepudiation bits may be provided in specific certificate policies. The keyEncipherment bit is asserted when the subject public key is used for key transport. For example, when an RSA key is to be used for key management, then this bit is set. The dataEncipherment bit is asserted when the subject public key is used for enciphering user data, other than cryptographic keys. The keyAgreement bit is asserted when the subject public key is used for key agreement. For example, when a Diffie-Hellman key is to be used for key management, then this bit is set. The keyCertSign bit is asserted when the subject public key is used for verifying a signature on public key certificates. If the keyCertSign bit is asserted, then the cA bit in the basic constraints extension (section 4.2.1.10) MUST also be asserted. The cRLSign bit is asserted when the subject public key is used for verifying a signature on certificate revocation list (e.g., a CRL, delta CRL, or an ARL). This bit MUST be asserted in certificates that are used to verify signatures on CRLs. The meaning of the encipherOnly bit is undefined in the absence of the keyAgreement bit. When the encipherOnly bit is asserted and the keyAgreement bit is also set, the subject public key may be used only for enciphering data while performing key agreement. The meaning of the decipherOnly bit is undefined in the absence of the keyAgreement bit. When the decipherOnly bit is asserted and the keyAgreement bit is also set, the subject public key may be used only for deciphering data while performing key agreement. This profile does not restrict the combinations of bits that may be set in an instantiation of the keyUsage extension. However, appropriate values for keyUsage extensions for particular algorithms are specified in [RFC 3279]. Instance Variables: bits <BitString> the key usage bits represented as a bit string
</comment> <class> <name>TBSCertificate</name> <environment>Security.X509</environment> <super>Security.X509.X509Object</super> <private>false</private> none encoding version serialNumber signature issuer validity subject subjectPublicKeyInfo extensions issuerUniqueID subjectUniqueID <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.TBSCertificate
This class represents the "to be signed" (TBS) part of the certificate, which represents most of the information that is contained in the certificate. RFC 3280 (section 4.1.2 TBSCertificate): The sequence TBSCertificate contains information associated with the subject of the certificate and the CA who issued it. Every TBSCertificate contains the names of the subject and issuer, a public key associated with the subject, a validity period, a version number, and a serial number; some MAY contain optional unique identifier fields. The remainder of this section describes the syntax and semantics of these fields. A TBSCertificate usually includes extensions. Extensions for the Internet PKI are described in Section 4.2. TBSCertificate ::= SEQUENCE { version [0] EXPLICIT Version DEFAULT v1, serialNumber CertificateSerialNumber, signature AlgorithmIdentifier, issuer Name, validity Validity, subject Name, subjectPublicKeyInfo SubjectPublicKeyInfo, issuerUniqueID [1] IMPLICIT UniqueIdentifier OPTIONAL, -- If present, version MUST be v2 or v3 subjectUniqueID [2] IMPLICIT UniqueIdentifier OPTIONAL, -- If present, version MUST be v2 or v3 extensions [3] EXPLICIT Extensions OPTIONAL -- If present, version MUST be v3 } 4.1.2.1 Version This field describes the version of the encoded certificate. When extensions are used, as expected in this profile, version MUST be 3 (value is 2). If no extensions are present, but a UniqueIdentifier is present, the version SHOULD be 2 (value is 1); however version MAY be 3. If only basic fields are present, the version SHOULD be 1 (the value is omitted from the certificate as the default value); however the version MAY be 2 or 3. Implementations SHOULD be prepared to accept any version certificate. At a minimum, conforming implementations MUST recognize version 3 certificates. Generation of version 2 certificates is not expected by implementations based on this profile. 4.1.2.2 Serial number The serial number MUST be a positive integer assigned by the CA to each certificate. It MUST be unique for each certificate issued by a given CA (i.e., the issuer name and serial number identify a unique certificate). CAs MUST force the serialNumber to be a non-negative integer. Given the uniqueness requirements above, serial numbers can be expected to contain long integers. Certificate users MUST be able to handle serialNumber values up to 20 octets. Conformant CAs MUST NOT use serialNumber values longer than 20 octets. Note: Non-conforming CAs may issue certificates with serial numbers that are negative, or zero. Certificate users SHOULD be prepared to gracefully handle such certificates. 4.1.2.3 Signature This field contains the algorithm identifier for the algorithm used by the CA to sign the certificate. This field MUST contain the same algorithm identifier as the signatureAlgorithm field in the sequence Certificate (section 4.1.1.2). The contents of the optional parameters field will vary according to the algorithm identified. [RFC 3279] lists the supported signature algorithms, but other signature algorithms MAY also be supported. 4.1.2.4 Issuer The issuer field identifies the entity who has signed and issued the certificate. The issuer field MUST contain a non-empty distinguished name (DN). The issuer field is defined as the X.501 type Name. 4.1.2.5 Validity The certificate validity period is the time interval during which the CA warrants that it will maintain information about the status of the certificate. The field is represented as a SEQUENCE of two dates: the date on which the certificate validity period begins (notBefore) and the date on which the certificate validity period ends (notAfter). Both notBefore and notAfter may be encoded as UTCTime or GeneralizedTime. 4.1.2.6 Subject The subject field identifies the entity associated with the public key stored in the subject public key field. The subject name MAY be carried in the subject field and/or the subjectAltName extension. If the subject is a CA (e.g., the basic constraints extension, as discussed in 4.2.1.10, is present and the value of cA is TRUE), then the subject field MUST be populated with a non-empty distinguished name matching the contents of the issuer field (section 4.1.2.4) in all certificates issued by the subject CA. If the subject is a CRL issuer (e.g., the key usage extension, as discussed in 4.2.1.3, is present and the value of cRLSign is TRUE) then the subject field MUST be populated with a non-empty distinguished name matching the contents of the issuer field (section 4.1.2.4) in all CRLs issued by the subject CRL issuer. If subject naming information is present only in the subjectAltName extension (e.g., a key bound only to an email address or URI), then the subject name MUST be an empty sequence and the subjectAltName extension MUST be critical. Where it is non-empty, the subject field MUST contain an X.500 distinguished name (DN). The DN MUST be unique for each subject entity certified by the one CA as defined by the issuer name field. A CA MAY issue more than one certificate with the same DN to the same subject entity. The subject name field is defined as the X.501 type Name. Implementation requirements for this field are those defined for the issuer field (section 4.1.2.4). When encoding attribute values of type DirectoryString, the encoding rules for the issuer field MUST be implemented. Implementations of this specification MUST be prepared to receive subject names containing the attribute types required for the issuer field. Implementations of this specification SHOULD be prepared to receive subject names containing the recommended attribute types for the issuer field. The syntax and associated object identifiers (OIDs) for these attribute types are provided in the ASN.1 modules in Appendix A. Implementations of this specification MAY use these comparison rules to process unfamiliar attribute types (i.e., for name chaining). This allows implementations to process certificates with unfamiliar attributes in the subject name. In addition, legacy implementations exist where an RFC 822 name is embedded in the subject distinguished name as an EmailAddress attribute. The attribute value for EmailAddress is of type IA5String to permit inclusion of the character '@', which is not part of the PrintableString character set. EmailAddress attribute values are not case sensitive (e.g., "fanfeedback@redsox.com" is the same as "FANFEEDBACK@REDSOX.COM"). Conforming implementations generating new certificates with electronic mail addresses MUST use the rfc822Name in the subject alternative name field (section 4.2.1.7) to describe such identities. Simultaneous inclusion of the EmailAddress attribute in the subject distinguished name to support legacy implementations is deprecated but permitted. 4.1.2.7 Subject Public Key Info This field is used to carry the public key and identify the algorithm with which the key is used (e.g., RSA, DSA, or Diffie-Hellman). 4.1.2.8 Unique Identifiers These fields MUST only appear if the version is 2 or 3 (section 4.1.2.1). These fields MUST NOT appear if the version is 1. The subject and issuer unique identifiers are present in the certificate to handle the possibility of reuse of subject and/or issuer names over time. This profile RECOMMENDS that names not be reused for different entities and that Internet certificates not make use of unique identifiers. CAs conforming to this profile SHOULD NOT generate certificates with unique identifiers. Applications conforming to this profile SHOULD be capable of parsing unique identifiers. 4.1.2.9 Extensions This field MUST only appear if the version is 3 (section 4.1.2.1). If present, this field is a SEQUENCE of one or more certificate extensions. The format and content of certificate extensions in the Internet PKI is defined in section 4.2. Instance Variables: encoding <Asn1Encoding> DER encoding of myself version <Integer> certificate format version serialNumber <Integer> a unique number assigned to the certificate by the issuer signature <X509AlgorithmIdentifier> identifies the algorithm used to sign the certificate issuer <X509Name> the name of the certificate issuer, authority issuing the certificate validity <X509Validity> indicates the validity period of the certificate subject <X509Name> the name of the certificate subject, for whom the certificate was issued subjectPublicKeyInfo <X509SubjectPublicKeyInfo> subject's public key extensions <OrderedCollection of: X509Extension> certificate extensions, only for version 3 certificates issuerUniqueID <Asn1BitString> optional, only version 2 and 3 certificates subjectUniqueID <Asn1BitString> optional, only version 2 and 3 certificates
</comment> <class> <name>BadCACertificate</name> <environment>Security.X509</environment> <super>Security.X509.X509Warning</super> <private>false</private> none <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.BadCACertificate
Abstract superclass for all invalid CA certificate errors.
</comment> <class> <name>BadCAKeyUsage</name> <environment>Security.X509</environment> <super>Security.X509.BadCACertificate</super> <private>false</private> none <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.BadCAKeyUsage
Indicates that a supposed CA certificate is missing KeyUsage extension or that the indicated key usage is not appropriate for a CA certificate.
</comment> <class> <name>IssuerMismatch</name> <environment>Security.X509</environment> <super>Security.X509.X509Warning</super> <private>false</private> none <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.IssuerMismatch
Indicates that a supposed issuer certificate doesn't match the issuer field of the subject certificate.
</comment> <class> <name>CertificateFileReader</name> <environment>Security.X509</environment> <super>Core.Object</super> <private>false</private> none stream <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.CertificateFileReader
This class parses a PEM file filled with certificates and private key pairs and return a collection of certificate -> key associations. Instance Variables: stream <Object> undocumented
</comment> <class> <name>Revoked</name> <environment>Security.X509</environment> <super>Security.X509.X509Warning</super> <private>false</private> none <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.Revoked
Indicates that a certificate was revoked
</comment> <class> <name>X509PrivateKey</name> <environment>Security.X509</environment> <super>Security.X509.X509Object</super> <private>false</private> none <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.X509PrivateKey
Common superclass of all private keys in X509. Provides instance creation utilities for reading private keys from external storage formats.
</comment> <class> <name>BadCAConstraints</name> <environment>Security.X509</environment> <super>Security.X509.BadCACertificate</super> <private>false</private> none <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.BadCAConstraints
Indicates that a supposed CA certificate is missing BasicConstraints extension.
</comment> <class> <name>X509PublicKey</name> <environment>Security.X509</environment> <super>Security.X509.X509Object</super> <private>false</private> none algorithmOID <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.X509PublicKey
Common superclass of all public keys in X509. RFC 3279 (section 2.3 Subject Public Key Algorithms): Certificates conforming to [RFC 3280] may convey a public key for any public key algorithm. The certificate indicates the algorithm through an algorithm identifier. This algorithm identifier is an OID and optionally associated parameters. This section identifies preferred OIDs and parameters for the RSA, DSA, Diffie-Hellman, KEA, ECDSA, and ECDH algorithms. Conforming CAs MUST use the identified OIDs when issuing certificates containing public keys for these algorithms. Conforming applications supporting any of these algorithms MUST, at a minimum, recognize the OID identified in this section. Class Instance Variables: algorithmOID <Asn1OID> caches the algorithm OID as prescribed by RFC#3279
</comment> <class> <name>X509DSAPublicKey</name> <environment>Security.X509</environment> <super>Security.X509.X509PublicKey</super> <private>false</private> none publicKey dssParameters <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.X509DSAPublicKey
Public key for the DSS signature standard. RFC 3279 (section 2.3.2 DSA Signature Keys): The Digital Signature Algorithm (DSA) is defined in the Digital Signature Standard (DSS) [FIPS 186]. The DSA OID supported by this profile is: id-dsa OBJECT IDENTIFIER ::= {iso(1) member-body(2) us(840) x9-57(10040) x9cm(4) 1 } The id-dsa algorithm syntax includes optional domain parameters. These parameters are commonly referred to as p, q, and g. When omitted, the parameters component MUST be omitted entirely. That is, the AlgorithmIdentifier MUST be a SEQUENCE of one component: the OBJECT IDENTIFIER id-dsa. If the DSA domain parameters are present in the subjectPublicKeyInfo AlgorithmIdentifier, the parameters are included using the following ASN.1 structure: Dss-Parms ::= SEQUENCE { p INTEGER, q INTEGER, g INTEGER } The AlgorithmIdentifier within subjectPublicKeyInfo is the only place within a certificate where the parameters may be used. If the DSA algorithm parameters are omitted from the subjectPublicKeyInfo AlgorithmIdentifier and the CA signed the subject certificate using DSA, then the certificate issuer's DSA parameters apply to the subject's DSA key. If the DSA domain parameters are omitted from the SubjectPublicKeyInfo AlgorithmIdentifier and the CA signed the subject certificate using a signature algorithm other than DSA, then the subject's DSA domain parameters are distributed by other means. If the subjectPublicKeyInfo AlgorithmIdentifier field omits the parameters component, the CA signed the subject with a signature algorithm other than DSA, and the subject's DSA parameters are not available through other means, then clients MUST reject the certificate. The DSA public key MUST be ASN.1 DER encoded as an INTEGER; this encoding shall be used as the contents (i.e., the value) of the subjectPublicKey component (a BIT STRING) of the SubjectPublicKeyInfo data element. DSAPublicKey ::= INTEGER -- public key, Y If the keyUsage extension is present in an end entity certificate which conveys a DSA public key, any combination of the following values MAY be present: digitalSignature; nonRepudiation; If the keyUsage extension is present in a CA or CRL issuer certificate which conveys a DSA public key, any combination of the following values MAY be present: digitalSignature; nonRepudiation; keyCertSign; and cRLSign. Instance Variables: publicKey <Object> undocumented dssParameters <Object> undocumented Class Instance Variables:
</comment> <class> <name>ValidityError</name> <environment>Security.X509</environment> <super>Security.X509.X509Warning</super> <private>false</private> none <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.ValidityError
Abstract superclass of all validity errors.
</comment> <class> <name>NotValidYet</name> <environment>Security.X509</environment> <super>Security.X509.ValidityError</super> <private>false</private> none <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.NotValidYet
Indicates that a certificate is not valid yet.
</comment> <class> <name>DSSSignatureValue</name> <environment>Security.X509</environment> <super>Security.X509.X509Object</super> <private>false</private> none r s <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.DSSSignatureValue
RFC 3279 (section 2.2.2 DSA Signature Algorithm): When signing, the DSA algorithm generates two values. These values are commonly referred to as r and s. To easily transfer these two values as one signature, they SHALL be ASN.1 encoded using the following ASN.1 structure: Dss-Sig-Value ::= SEQUENCE { r INTEGER, s INTEGER } Instance Variables: r <Integer> s <Integer>
</comment> <class> <name>NoExtensionSupport</name> <environment>Security.X509</environment> <super>Security.X509.X509Error</super> <private>false</private> none <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.NoExtensionSupport
This error is signaled when there is an attempt to create extensions in a certificate with version that does not support extensions.
</comment> <class> <name>X509Notification</name> <environment>Security.X509</environment> <super>Security.X509.X509Exception</super> <private>false</private> none <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.X509Notification
Abstract superclass of all X509 notifications, usually things that don't satisfy the stated requirements of the X.509 specification but aren't as serious as X509Warnings.
</comment> <class> <name>ExtensionShouldBeCritical</name> <environment>Security.X509</environment> <super>Security.X509.X509Notification</super> <private>false</private> none extension <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.ExtensionShouldBeCritical
Indicates that a certificate has an extension which should have been marked critical, but isn't. Instance Variables: extension <Object> undocumented
</comment> <class> <name>InvalidSignature</name> <environment>Security.X509</environment> <super>Security.X509.BadCertificate</super> <private>false</private> none <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.InvalidSignature
Indicates that the signature of a certificate is not valid.
</comment> <class> <name>AttributeValueAssertion</name> <environment>Security.X509</environment> <super>Security.X509.X509Object</super> <private>false</private> none type value <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.AttributeValueAssertion
These are components of X509Name, each assertion qualifies a string with a "type". Types are denoted using OIDs. RFC 3280 (section 4.1.2.4 Issuer): As noted above, distinguished names are composed of attributes. This specification does not restrict the set of attribute types that may appear in names. However, conforming implementations MUST be prepared to receive certificates with issuer names containing the set of attribute types defined below. This specification RECOMMENDS support for additional attribute types. Standard sets of attributes have been defined in the X.500 series of specifications [X.520]. Implementations of this specification MUST be prepared to receive the following standard attribute types in issuer and subject (section 4.1.2.6) names: * country, * organization, * organizational-unit, * distinguished name qualifier, * state or province name, * common name (e.g., "Susan Housley"), and * serial number. In addition, implementations of this specification SHOULD be prepared to receive the following standard attribute types in issuer and subject names: * locality, * title, * surname, * given name, * initials, * pseudonym, and * generation qualifier (e.g., "Jr.", "3rd", or "IV"). The syntax and associated object identifiers (OIDs) for these attribute types are provided in the ASN.1 modules in Appendix A. In addition, implementations of this specification MUST be prepared to receive the domainComponent attribute, as defined in [RFC 2247]. The Domain Name System (DNS) provides a hierarchical resource labeling system. This attribute provides a convenient mechanism for organizations that wish to use DNs that parallel their DNS names. This is not a replacement for the dNSName component of the alternative name field. Implementations are not required to convert such names into DNS names. The syntax and associated OID for this attribute type is provided in the ASN.1 modules in Appendix A. AttributeTypeAndValue ::= SEQUENCE { type AttributeType, value AttributeValue } AttributeType ::= OBJECT IDENTIFIER AttributeValue ::= ANY DEFINED BY AttributeType DirectoryString ::= CHOICE { teletexString TeletexString (SIZE (1..MAX)), printableString PrintableString (SIZE (1..MAX)), universalString UniversalString (SIZE (1..MAX)), utf8String UTF8String (SIZE (1..MAX)), bmpString BMPString (SIZE (1..MAX)) } The type of the component AttributeValue is determined by the AttributeType; in general it will be a DirectoryString. The DirectoryString type is defined as a choice of PrintableString, TeletexString, BMPString, UTF8String, and UniversalString. The UTF8String encoding [RFC 2279] is the preferred encoding, and all certificates issued after December 31, 2003 MUST use the UTF8String encoding of DirectoryString (except as noted below). Until that date, conforming CAs MUST choose from the following options when creating a distinguished name, including their own: (a) if the character set is sufficient, the string MAY be represented as a PrintableString; (b) failing (a), if the BMPString character set is sufficient the string MAY be represented as a BMPString; and (c) failing (a) and (b), the string MUST be represented as a UTF8String. If (a) or (b) is satisfied, the CA MAY still choose to represent the string as a UTF8String. Exceptions to the December 31, 2003 UTF8 encoding requirements are as follows: (a) CAs MAY issue "name rollover" certificates to support an orderly migration to UTF8String encoding. Such certificates would include the CA's UTF8String encoded name as issuer and and the old name encoding as subject, or vice-versa. (b) As stated in section 4.1.2.6, the subject field MUST be populated with a non-empty distinguished name matching the contents of the issuer field in all certificates issued by the subject CA regardless of encoding. The TeletexString and UniversalString are included for backward compatibility, and SHOULD NOT be used for certificates for new subjects. However, these types MAY be used in certificates where the name was previously established. Certificate users SHOULD be prepared to receive certificates with these types. In addition, many legacy implementations support names encoded in the ISO 8859-1 character set (Latin1String) [ISO 8859-1] but tag them as TeletexString. TeletexString encodes a larger character set than ISO 8859-1, but it encodes some characters differently. Implementations SHOULD be prepared to handle both encodings. Instance Variables: type <Asn1OID> denotes the type of name component, (OU, O, CN, L, S, ...) value <String> value of the name component
</comment> <class> <name>X509RSAPublicKey</name> <environment>Security.X509</environment> <super>Security.X509.X509PublicKey</super> <private>false</private> none e n <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.X509RSAPublicKey
Public key for RSA signing/encryption algorithm. RFC 3279 (section 2.3.1 RSA Keys): The OID rsaEncryption identifies RSA public keys. pkcs-1 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) 1 } rsaEncryption OBJECT IDENTIFIER ::= { pkcs-1 1} The rsaEncryption OID is intended to be used in the algorithm field of a value of type AlgorithmIdentifier. The parameters field MUST have ASN.1 type NULL for this algorithm identifier. The RSA public key MUST be encoded using the ASN.1 type RSAPublicKey: RSAPublicKey ::= SEQUENCE { modulus INTEGER, -- n publicExponent INTEGER } -- e where modulus is the modulus n, and publicExponent is the public exponent e. The DER encoded RSAPublicKey is the value of the BIT STRING subjectPublicKey. This OID is used in public key certificates for both RSA signature keys and RSA encryption keys. The intended application for the key MAY be indicated in the key usage field (see [RFC 3280]). The use of a single key for both signature and encryption purposes is not recommended, but is not forbidden. If the keyUsage extension is present in an end entity certificate which conveys an RSA public key, any combination of the following values MAY be present: digitalSignature; nonRepudiation; keyEncipherment; and dataEncipherment. If the keyUsage extension is present in a CA or CRL issuer certificate which conveys an RSA public key, any combination of the following values MAY be present: digitalSignature; nonRepudiation; keyEncipherment; dataEncipherment; keyCertSign; and cRLSign. However, this specification RECOMMENDS that if keyCertSign or cRLSign is present, both keyEncipherment and dataEncipherment SHOULD NOT be present. Instance Variables: e <Object> undocumented n <Object> undocumented Class Instance Variables:
</comment> <class> <name>BasicConstraints</name> <environment>Security.X509</environment> <super>Security.X509.Extension</super> <private>false</private> none ca depth <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.BasicConstraints
RFC 3280 (section 4.2.1.10): The basic constraints extension identifies whether the subject of the certificate is a CA and the maximum depth of valid certification paths that include this certificate. The cA boolean indicates whether the certified public key belongs to a CA. If the cA boolean is not asserted, then the keyCertSign bit in the key usage extension MUST NOT be asserted. The pathLenConstraint field is meaningful only if the cA boolean is asserted and the key usage extension asserts the keyCertSign bit (section 4.2.1.3). In this case, it gives the maximum number of non-self-issued intermediate certificates that may follow this certificate in a valid certification path. A certificate is self-issued if the DNs that appear in the subject and issuer fields are identical and are not empty. (Note: The last certificate in the certification path is not an intermediate certificate, and is not included in this limit. Usually, the last certificate is an end entity certificate, but it can be a CA certificate.) A pathLenConstraint of zero indicates that only one more certificate may follow in a valid certification path. Where it appears, the pathLenConstraint field MUST be greater than or equal to zero. Where pathLenConstraint does not appear, no limit is imposed. This extension MUST appear as a critical extension in all CA certificates that contain public keys used to validate digital signatures on certificates. This extension MAY appear as a critical or non-critical extension in CA certificates that contain public keys used exclusively for purposes other than validating digital signatures on certificates. Such CA certificates include ones that contain public keys used exclusively for validating digital signatures on CRLs and ones that contain key management public keys used with certificate enrollment protocols. This extension MAY appear as a critical or non-critical extension in end entity certificates. CAs MUST NOT include the pathLenConstraint field unless the cA boolean is asserted and the key usage extension asserts the keyCertSign bit. id-ce-basicConstraints OBJECT IDENTIFIER ::= { id-ce 19 } BasicConstraints ::= SEQUENCE { cA BOOLEAN DEFAULT FALSE, pathLenConstraint INTEGER (0..MAX) OPTIONAL } Instance Variables: ca <Boolean> is the subject a certificate issuing authority ? depth <Integer> maximum depth of valid certification paths that include this certificate
</comment> <class> <name>Expired</name> <environment>Security.X509</environment> <super>Security.X509.ValidityError</super> <private>false</private> none <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.Expired
Indicates that a certificate has expired.
</comment> <class> <name>X509RSAPrivateKey</name> <environment>Security.X509</environment> <super>Security.X509.X509PrivateKey</super> <private>false</private> none version d n e p q exponent1 exponent2 coefficient <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.X509RSAPrivateKey
Private key for RSA signature/encryption algorithm. The ASN.1 representation is described in PKCS#1, section A.1.2, RSA private key syntax: An RSA private key should be represented with the ASN.1 type RSAPrivateKey: RSAPrivateKey ::= SEQUENCE { version Version, modulus INTEGER, -- n publicExponent INTEGER, -- e privateExponent INTEGER, -- d prime1 INTEGER, -- p prime2 INTEGER, -- q exponent1 INTEGER, -- d mod (p-1) exponent2 INTEGER, -- d mod (q-1) coefficient INTEGER, -- (inverse of q) mod p otherPrimeInfos OtherPrimeInfos OPTIONAL } The fields of type RSAPrivateKey have the following meanings: * version is the version number, for compatibility with future revisions of this document. It shall be 0 for this version of the document, unless multi-prime is used, in which case it shall be 1. Version ::= INTEGER { two-prime(0), multi(1) } (CONSTRAINED BY {-- version must be multi if otherPrimeInfos present --}) * modulus is the RSA modulus n. * publicExponent is the RSA public exponent e. * privateExponent is the RSA private exponent d. * prime1 is the prime factor p of n. * prime2 is the prime factor q of n. * exponent1 is d mod (p - 1). * exponent2 is d mod (q - 1). * coefficient is the CRT coefficient q^-1 mod p. * otherPrimeInfos contains the information for the additional primes r3, ... , ru, in order. It shall be omitted if version is 0 and shall contain at least one instance of OtherPrimeInfo if version is 1. OtherPrimeInfos ::= SEQUENCE SIZE(1..MAX) OF OtherPrimeInfo OtherPrimeInfo ::= SEQUENCE { prime INTEGER, -- ri exponent INTEGER, -- di coefficient INTEGER -- ti } The fields of type OtherPrimeInfo have the following meanings: * prime is a prime factor ri of n, where i >= 3. * exponent is di = d mod (ri - 1). * coefficient is the CRT coefficient ti = (r1 * r2 * ... * r(i-1))^-1 mod ri. Instance Variables: version <Integer> d <Integer> private exponent n <Integer> modulus e <Integer> public exponent p <Integer> prime factor 1 q <Integer> prime factor 2 exponent1 <Integer> d mod (p - 1). exponent2 <Integer> d mod (q - 1). coefficient <Integer> the CRT coefficient q^-1 mod p.
</comment> <class> <name>AlgorithmIdentifier</name> <environment>Security.X509</environment> <super>Security.X509.X509Object</super> <private>false</private> none oid oidDescription parameters <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.AlgorithmIdentifier
RFC 3280 (section 4.1.1.2 signatureAlgorithm): The signatureAlgorithm field contains the identifier for the cryptographic algorithm used by the CA to sign this certificate. [RFC 3279] lists supported signature algorithms, but other signature algorithms MAY also be supported. An algorithm identifier is defined by the following ASN.1 structure: AlgorithmIdentifier ::= SEQUENCE { algorithm OBJECT IDENTIFIER, parameters ANY DEFINED BY algorithm OPTIONAL } The OBJECT IDENTIFIER component identifies the algorithm (such as DSA with SHA-1). The contents of the optional parameters field will vary according to the algorithm identified. This field MUST contain the same algorithm identifier as the signature field in the sequence tbsCertificate (section 4.1.2.3). Instance Variables: oid <Asn1OID> oidDescription <String> parameters <Object> optional signing algorithm parameters
</comment> <class> <name>Unsupported</name> <environment>Security.X509</environment> <super>Security.X509.X509Warning</super> <private>false</private> none <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.Unsupported
Indicates an unsupported feature, e.g. an unsupported signature algorithm.
</comment> <class> <name>SubjectPublicKeyInfo</name> <environment>Security.X509</environment> <super>Security.X509.X509Object</super> <private>false</private> none algorithm subjectPublicKey publicKey <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.SubjectPublicKeyInfo
RFC 3280 (section 4.1.2.7 Subject Public Key Info): This field is used to carry the public key and identify the algorithm with which the key is used (e.g., RSA, DSA, or Diffie-Hellman). The algorithm is identified using the AlgorithmIdentifier structure specified in section 4.1.1.2. The object identifiers for the supported algorithms and the methods for encoding the public key materials (public key and parameters) are specified in [RFC 3279]. SubjectPublicKeyInfo ::= SEQUENCE { algorithm AlgorithmIdentifier, subjectPublicKey BIT STRING } Instance Variables: algorithm <X509AlgorithmIdentifier> subjectPublicKey <BitString> DER encoded key structure (defined by the OID) publicKey <X509PublicKey> unmarshaled public key instance
</comment> <class> <name>UnhandledCriticalExtension</name> <environment>Security.X509</environment> <super>Security.X509.Unsupported</super> <private>false</private> none extension <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.UnhandledCriticalExtension
Indicates that a certificate has an extension which is marked as critical, but we don't know how to handle it. Instance Variables: extension <Object> undocumented
</comment> <class> <name>X509DSAPrivateKey</name> <environment>Security.X509</environment> <super>Security.X509.X509PrivateKey</super> <private>false</private> none version p q g x y <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.X509DSAPrivateKey
Private key for DSS signature standard. The ASN.1 representation is derived from the DER format used by OpenSSL. It is described in the man page for the dsa command, DSA(1) as follows: "This specifies the input format. The DER option with a private key uses an ASN1 DER encoded form of an ASN.1 SEQUENCE consisting of the values of version (currently zero), p, q, g, the public and private key components respectively as ASN.1 INTEGERs." Instance Variables: version <Integer> p <LargeInteger> q <LargeInteger> g <LargeInteger> x <LargeInteger> y <LargeInterger>
</comment> <class> <name>Certificate</name> <environment>Security.X509</environment> <super>Security.X509.X509Object</super> <private>false</private> none encoding tbsCertificate signatureAlgorithm signatureValue signature <imports></imports> <category>Security-Certificates</category> <attributes> <package>X509</package> </attributes> </class> <comment> Security.X509.Certificate
RFC 3280 (section 3.1 X.509 Version 3 Certificate): Users of a public key require confidence that the associated private key is owned by the correct remote subject (person or system) with which an encryption or digital signature mechanism will be used. This confidence is obtained through the use of public key certificates, which are data structures that bind public key values to subjects. The binding is asserted by having a trusted CA digitally sign each certificate. The CA may base this assertion upon technical means (a.k.a., proof of possession through a challenge-response protocol), presentation of the private key, or on an assertion by the subject. A certificate has a limited valid lifetime which is indicated in its signed contents. Because a certificate's signature and timeliness can be independently checked by a certificate-using client, certificates can be distributed via untrusted communications and server systems, and can be cached in unsecured storage in certificate-using systems. ITU-T X.509 (formerly CCITT X.509) or ISO/IEC 9594-8, which was first published in 1988 as part of the X.500 Directory recommendations, defines a standard certificate format [X.509]. The certificate format in the 1988 standard is called the version 1 (v1) format. When X.500 was revised in 1993, two more fields were added, resulting in the version 2 (v2) format. The Internet Privacy Enhanced Mail (PEM) RFCs, published in 1993, include specifications for a public key infrastructure based on X.509 v1 certificates [RFC 1422]. The experience gained in attempts to deploy RFC 1422 made it clear that the v1 and v2 certificate formats are deficient in several respects. Most importantly, more fields were needed to carry information which PEM design and implementation experience had proven necessary. In response to these new requirements, ISO/IEC, ITU-T and ANSI X9 developed the X.509 version 3 (v3) certificate format. The v3 format extends the v2 format by adding provision for additional extension fields. Particular extension field types may be specified in standards or may be defined and registered by any organization or community. In June 1996, standardization of the basic v3 format was completed [X.509]. ISO/IEC, ITU-T, and ANSI X9 have also developed standard extensions for use in the v3 extensions field [X.509][X9.55]. These extensions can convey such data as additional subject identification information, key attribute information, policy information, and certification path constraints. However, the ISO/IEC, ITU-T, and ANSI X9 standard extensions are very broad in their applicability. In order to develop interoperable implementations of X.509 v3 systems for Internet use, it is necessary to specify a profile for use of the X.509 v3 extensions tailored for the Internet. It is one goal of this document to specify a profile for Internet WWW, electronic mail, and IPsec applications. Environments with additional requirements may build on this profile or may replace it. 4.1 Basic Certificate Fields The X.509 v3 certificate basic syntax is as follows. For signature calculation, the data that is to be signed is encoded using the ASN.1 distinguished encoding rules (DER) [X.690]. ASN.1 DER encoding is a tag, length, value encoding system for each element. Certificate ::= SEQUENCE { tbsCertificate TBSCertificate, signatureAlgorithm AlgorithmIdentifier, signatureValue BIT STRING } The signatureAlgorithm field contains the identifier for the cryptographic algorithm used by the CA to sign this certificate. The signatureValue field contains a digital signature computed upon the ASN.1 DER encoded tbsCertificate. The ASN.1 DER encoded tbsCertificate is used as the input to the signature function. This signature value is encoded as a BIT STRING and included in the signature field. The details of this process are specified for each of algorithms listed in [RFC 3279]. By generating this signature, a CA certifies the validity of the information in the tbsCertificate field. In particular, the CA certifies the binding between the public key material and the subject of the certificate. Instance Variables: encoding <Asn1Encoding> DER enconding of myself tbsCertificate <X509TBSCertificate> "to be signed" certificate, the data part signatureAlgorithm <X509AlgorithmIdentifier> identifies the algorithm used to sign the certificate signatureValue <BitString> caches marshaler friendly bit string version of the signature signature <ByteArray | X509DSSSignatureValue> signature value
</comment> <name>OIDToDescription</name> <environment>Security.X509.Name</environment> <private>false</private> <constant>false</constant> <category>ssl</category> <initializer>Name buildOIDToDescription</initializer> <attributes> <package>X509</package> </attributes> <name>X509Certificate</name> <environment>Security</environment> <private>true</private> <constant>true</constant> <category>backward compatibility</category> <initializer>Security.X509.Certificate</initializer> <attributes> <package>X509</package> </attributes> <name>DefaultCertificateFile</name> <environment>Security.X509.X509Registry</environment> <private>false</private> <constant>false</constant> <category>Certificates</category> <attributes> <package>X509</package> </attributes> <name>ShouldBeStrict</name> <environment>Security.X509.X509Registry</environment> <private>false</private> <constant>false</constant> <category>Certificates</category> <initializer>false</initializer> <attributes> <package>X509</package> </attributes> <name>ASN1Module</name> <environment>Security.X509.X509Object</environment> <private>false</private> <constant>false</constant> <category>accessing</category> <initializer>X509Object createModule</initializer> <attributes> <package>X509</package> </attributes> <methods> Security.X509.X509Warning <category>testing</category>
mayResume ^true
</methods> <methods> Security.X509.X509Object <category>accessing</category>
asn1Type ^self class asn1Type
</methods> <methods> Security.X509.X509Object <category>printing</category>
printOpenSSLOn: aStream indent: level "This should print the object in the format used by OpenSSL" "We need to raise DNU so that Trippy doesn't display the virtual attribute -openssl for objects that don't implement this" ^self doesNotUnderstand: ( Message selector: #printOpenSSLOn:indent: arguments: (Array with: aStream with: level))
printOpenSSLString "This should print the certificate in the format used by OpenSSL" | ws | ws := WriteStream on: (String new: 100). self printOpenSSLOn: ws indent: 0. ^ws contents
</methods> <methods> Security.X509.X509Object <category>utilities</category>
inspectorExtraAttributes ^#{Tools.Trippy.TextAttribute} ifDefinedDo: [ :class | Array with: (class label: 'openssl' text: self printOpenSSLString) ] elseDo: [ Array new ]
</methods> <methods> Security.X509.X509Object <category>writing</category>
writeOn: stream "Encode the receiver on the <stream>. stream <WriteStream> writable binary stream " (DERStream wrap: stream) marshalObject: self withType: self asn1Type
</methods> <methods> Security.X509.X509Object class <category>accessing</category>
asn1Type "The ASN.1 type corresponding to the key class" ^ASN1Module find: self asn1TypeName
asn1TypeName "The ASN.1 type name corresponding to the key class" ^self subclassResponsibility
createModule ^Module new: #X509
module ^ASN1Module ifNil: [ ASN1Module := self createModule ]
resetModule #{ASN1Module} binding reinitializeValue
</methods> <methods> Security.X509.X509Object class <category>utilities</category>
decodeBase64: aString | input stream output char | input := aString asByteArray readStream. stream := EncodedStream on: input encodedBy: Protocols.Base64StreamEncoder asEncoder. output := (ByteArray new: 64) writeStream. [ (char := stream next) notNil ] whileTrue: [ output nextPut: char ]. ^output contents
reinitialize "Reinitialize the X509 infrastructure self reinitialize " self reinitializeAsn1Types; reinitializeSMINodes
reinitializeAsn1Types "Reinitialize the ASN.1 type registry self reinitializeAsn1Types " self resetModule. (self allSubclasses select: [ :c | c class includesSelector: #initializeAsn1Types ]) do: [ :c | c initializeAsn1Types ]
reinitializeSMINodes "Reinitialize SMI node hierarchy for X509 self reinitializeSMINodes " (self allSubclasses select: [ :c | c class includesSelector: #initializeSMINodes ]) do: [ :c | c initializeSMINodes ]
stripWhitespace: aString | ws remove | ws := (String new: aString size) writeStream. remove := Array with: Character cr with: Character lf with: Character space with: Character tab. aString do: [ :c | (remove includes: c) ifFalse: [ ws nextPut: c ] ]. ^ws contents
</methods> <methods> Security.X509.X509Object class <category>initialize-release</category>
initialize self initializeSMINodes
initializeSMINodes "Add OIDs defined by RFC#3280: Appendix A. Psuedo-ASN.1 Structures and OIDs" SMINode root " -- PKIX specific OIDs id-pkix OBJECT IDENTIFIER ::= { iso(1) identified-organization(3) dod(6) internet(1) security(5) mechanisms(5) pkix(7) } " atPath: #(1 3 6 1 5 5 7) setSymbol: 'pkix'; " -- PKIX arcs id-pe OBJECT IDENTIFIER ::= { id-pkix 1 } -- arc for private certificate extensions id-qt OBJECT IDENTIFIER ::= { id-pkix 2 } -- arc for policy qualifier types id-kp OBJECT IDENTIFIER ::= { id-pkix 3 } -- arc for extended key purpose OIDS id-ad OBJECT IDENTIFIER ::= { id-pkix 48 } -- arc for access descriptors " atPath: #(1 3 6 1 5 5 7 1) setSymbol: 'pe'; atPath: #(1 3 6 1 5 5 7 2) setSymbol: 'qt'; atPath: #(1 3 6 1 5 5 7 3) setSymbol: 'kp'; atPath: #(1 3 6 1 5 5 7 48) setSymbol: 'ad'; " -- policyQualifierIds for Internet policy qualifiers id-qt-cps OBJECT IDENTIFIER ::= { id-qt 1 } -- OID for CPS qualifier id-qt-unotice OBJECT IDENTIFIER ::= { id-qt 2 } -- OID for user notice qualifier " atPath: #(1 3 6 1 5 5 7 2 1) setSymbol: 'cps'; atPath: #(1 3 6 1 5 5 7 2 2) setSymbol: 'unotice'; " -- access descriptor definitions id-ad-ocsp OBJECT IDENTIFIER ::= { id-ad 1 } id-ad-caIssuers OBJECT IDENTIFIER ::= { id-ad 2 } id-ad-timeStamping OBJECT IDENTIFIER ::= { id-ad 3 } id-ad-caRepository OBJECT IDENTIFIER ::= { id-ad 5 } " atPath: #(1 3 6 1 5 5 7 48 1) setSymbol: 'ocsp'; atPath: #(1 3 6 1 5 5 7 48 2) setSymbol: 'caIssuers'; atPath: #(1 3 6 1 5 5 7 48 3) setSymbol: 'timeStamping'; atPath: #(1 3 6 1 5 5 7 48 5) setSymbol: 'caRepository'; yourself
</methods> <methods> Security.X509.X509Object class <category>instance creation</category>
readFrom: stream "Decode an instance of the receiver from the <stream>. stream <ReadStream> readable binary stream " ^(DERStream wrap: stream) unmarshalObjectType: self asn1Type
</methods> <methods> Security.X509.Validity <category>accessing</category>
notAfterDate "date component of notAfter" ^self notAfterTimestamp asDate
notAfterTime "time component of notAfter" ^self notAfterTimestamp asTime.
notAfterTimestamp ^notAfter _value
notAfterTimestamp: aTimestamp self notAfter: (self choiceFrom: aTimestamp)
notBeforeDate "date component of notBefore" ^self notBeforeTimestamp asDate.
notBeforeTime "time component of notBefore" ^self notBeforeTimestamp asTime.
notBeforeTimestamp ^notBefore _value
notBeforeTimestamp: aTimestamp self notBefore: (self choiceFrom: aTimestamp)
</methods> <methods> Security.X509.Validity <category>marshaling</category>
notAfter ^notAfter
notAfter: anAsn1Choice notAfter := anAsn1Choice
notBefore ^notBefore
notBefore: anAsn1Choice notBefore := anAsn1Choice
</methods> <methods> Security.X509.Validity <category>printing</category>
printOpenSSLOn: aStream indent: level "This should print the certificate in the format used by OpenSSL" | format | format := 'mmm d hh:mm:ss yyyy'. aStream tab: level; nextPutAll: (#NotBeforePrefix << #security >> 'Not Before: ') asString. TimestampPrintPolicy print: self notBeforeGMT on: aStream using: format. aStream nextPutAll: (#GMTPrefix << #security >> ' GMT') asString; cr; tab: level; nextPutAll: (#NotAfterPrefix << #security >> 'Not After : ') asString. TimestampPrintPolicy print: self notAfterGMT on: aStream using: format. aStream nextPutAll: (#GMTPrefix << #security >> ' GMT') asString
</methods> <methods> Security.X509.Validity <category>testing</category>
isExpired ^self isExpiredOn: Timestamp now
isExpiredOn: time ^self notAfter asSeconds < time asSeconds
isNotValidYet ^self isNotValidYetOn: Timestamp now
isNotValidYetOn: time ^time asSeconds < self notBefore asSeconds
isValid ^self isValidOn: Timestamp now
isValidOn: time ^((self isExpiredOn: time) or: [ self isNotValidYetOn: time ]) not
</methods> <methods> Security.X509.Validity <category>private</category>
choiceFrom: aTimestamp "RFC: ... CAs conforming to this profile MUST always encode certificate validity dates through the year 2049 as UTCTime; certificate validity dates in 2050 or later MUST be encoded as GeneralizedTime..." ^Choice type: (ASN1Module find: #Time) choiceSymbol: (aTimestamp year < 2050 ifTrue: [ #utcTime ] ifFalse: [ #generalTime ]) value: aTimestamp
convertToGMT: aTimestamp ^TimeZone reference convertToGMT: aTimestamp asSeconds do: [ :date :seconds | Timestamp fromDate: date andTime: (Time fromSeconds: seconds) ]
notAfterGMT ^self convertToGMT: notAfter
notBeforeGMT ^self convertToGMT: notBefore
</methods> <methods> Security.X509.Validity class <category>initialize-release</category>
initialize self initializeAsn1Types
initializeAsn1Types " Validity ::= SEQUENCE { notBefore Time, notAfter Time } " ( ASN1Module SEQUENCE: #Validity ) addElement: #notBefore type: #Time; addElement: #notAfter type: #Time; mapping: self. " Time ::= CHOICE { utcTime UTCTime, generalTime GeneralizedTime } " ( ASN1Module CHOICE: #Time ) addElement: #utcTime type: #UTCTime; addElement: #generalTime type: #GeneralizedTime.
</methods> <methods> Security.X509.Validity class <category>accessing</category>
asn1TypeName ^#Validity
</methods> <methods> Security.X509.Extension <category>accessing</category>
critical ^critical
critical: aBoolean critical := aBoolean. (self shouldBeCritical and: [ aBoolean not ]) ifTrue: [ ExtensionShouldBeCritical new messageText: ((#CertExtShouldBeCritical1p<< #security >> 'Certificate extension <1p> should be critical') expandMacrosWith: self class); parameter: self; isResumable: true; raiseSignal ].
oid ^oid
oid: anOID oid := anOID
value "the value" ^value
value: anObject value := anObject
</methods> <methods> Security.X509.Extension <category>testing</category>
isBasicConstraints ^false
isCritical " the value of the instance variable critical" ^self critical
isHandled ^false
isKeyUsage ^false
isSubjectAltName ^false
isSubjectKeyIdentifier ^false
shouldBeCritical ^false
</methods> <methods> Security.X509.Extension <category>marshaling</category>
asn1Value ^self
extnID ^oid
extnID: anOID self oid: anOID
extnValue ^value ifNil: [ | stream | stream := DERStream on: (ByteArray new: 20). stream marshalObject: self asn1Value withType: self asn1Type. value := stream contents ].
extnValue: aByteArray value := aByteArray. (self class extensionClassFor: oid) ifNotNil: [ :class || extension | extension := aByteArray. class asn1Type ifNotNil: [ :type || stream | stream := DERStream with: aByteArray. stream reset. extension := stream unmarshalObjectType: type ]. "Some extensions are simple types that the ASN.1 framework can't map to class automatically, so we need to work around that here" extension := class adoptValue: extension. extension oid: oid; critical: critical; value: value. self become: extension ]
</methods> <methods> Security.X509.Extension <category>initialize-release</category>
initialize self class oid ifNotNil: [ :id | self oid: id ]. self shouldBeCritical ifTrue: [ self critical: true ]
</methods> <methods> Security.X509.Extension <category>printing</category>
id "OID for the extension" ^oid getDottedOID
idDescription " the description of the OID for the extension" ^oid ifNil: [''] ifNotNil: [ [ oid getOIDDescription ] on: SMIUnknownPath do: [ :ex | ex return: '' ] ]
printOpenSSLOn: aStream indent: level "This should print the extension in the format used by OpenSSL" aStream cr; tab: level; nextPutAll: ( self class = Extension ifTrue: [ oid getDottedOID ] ifFalse: [ self class name ]); nextPut: $:. critical ifTrue: [aStream nextPutAll: (#CriticalSuffix << #security >> ' critical') asString].
</methods> <methods> Security.X509.Extension <category>writing</category>
writeOn: stream "Encode the receiver on the <stream>. stream <WriteStream> writable binary stream " (DERStream wrap: stream) marshalObject: self asn1Value withType: self asn1Type
</methods> <methods> Security.X509.Extension class <category>accessing</category>
asn1Type ^self asn1TypeName ifNotNil: [ :type | ASN1Module find: type ]
asn1TypeName ^nil
extensionClassFor: anOID ^Extension allSubclasses detect: [ :c | c oid = anOID ] ifNone: [ nil ]
oid ^oid ifNil: [ self oidString ifNotNil: [ :s | oid := s asAsn1OID ] ]
</methods> <methods> Security.X509.Extension class <category>private</category>
adoptValue: value "Some extensions are simple types that the ASN.1 framework can't map to class automatically, so we need to work around that here." "by default the extension is mappable so there's nothing that needs to be done; just return the value" ^value
oidString ^nil
</methods> <methods> Security.X509.Extension class <category>instance creation</category>
new ^super new initialize
readFrom: stream "Decode an instance of the receiver from the <stream>. stream <ReadStream> readable binary stream " ^self adoptValue: (super readFrom: stream)
</methods> <methods> Security.X509.Extension class <category>initialize-release</category>
initialize self initializeAsn1Types; initializeSMINodes
initializeAsn1Types " Extension ::= SEQUENCE { extnID OBJECT IDENTIFIER, critical BOOLEAN DEFAULT FALSE, extnValue OCTET STRING } " ( ASN1Module SEQUENCE: #Extension ) addElement: #extnID type: #'OBJECT IDENTIFIER'; addElement: #critical type: #BOOLEAN default: false; addElement: #extnValue type: #OCTET_STRING; mapping: self
initializeSMINodes "Add OIDs defined by RFC#3280: Appendix A. Psuedo-ASN.1 Structures and OIDs" SMINode root atPath: #( 2 5 29 ) setSymbol: 'ce'; atPath: #( 2 5 29 3 ) setSymbol: 'certificatePolicies'; atPath: #( 2 5 29 14 ) setSymbol: 'subjectKeyIdentifier'; atPath: #( 2 5 29 15 ) setSymbol: 'keyUsage'; atPath: #( 2 5 29 16 ) setSymbol: 'privateKeyUsagePeriod'; atPath: #( 2 5 29 17 ) setSymbol: 'subjectAltName'; atPath: #( 2 5 29 18 ) setSymbol: 'issuerAltName'; atPath: #( 2 5 29 19 ) setSymbol: 'basicConstraints'; atPath: #( 2 5 29 20 ) setSymbol: 'cRLNumber'; atPath: #( 2 5 29 21 ) setSymbol: 'reasonCode'; atPath: #( 2 5 29 23 ) setSymbol: 'instructionCode'; atPath: #( 2 5 29 24 ) setSymbol: 'invalidityDate'; atPath: #( 2 5 29 27 ) setSymbol: 'deltaCRLIndicator'; atPath: #( 2 5 29 28 ) setSymbol: 'issuingDistributionPoint'; atPath: #( 2 5 29 29 ) setSymbol: 'certificateIssuer'; atPath: #( 2 5 29 30 ) setSymbol: 'nameConstraints'; atPath: #( 2 5 29 31 ) setSymbol: 'cRLDistributionPoints'; atPath: #( 2 5 29 32 ) setSymbol: 'certificatePolicies'; atPath: #( 2 5 29 33 ) setSymbol: 'policyMappings'; atPath: #( 2 5 29 35 ) setSymbol: 'authorityKeyIdentifier'; atPath: #( 2 5 29 36 ) setSymbol: 'policyConstraints'; atPath: #( 2 5 29 37 ) setSymbol: 'extKeyUsage'; yourself
</methods> <methods> Security.X509.SubjectKeyIdentifier <category>accessing</category>
identifier ^identifier
identifier: aByteArray identifier := aByteArray
</methods> <methods> Security.X509.SubjectKeyIdentifier <category>testing</category>
isSubjectKeyIdentifier ^true
</methods> <methods> Security.X509.SubjectKeyIdentifier <category>initialize-release</category>
initialize: aByteArray identifier := aByteArray
</methods> <methods> Security.X509.SubjectKeyIdentifier <category>marshaling</category>
asn1Value ^self identifier
</methods> <methods> Security.X509.SubjectKeyIdentifier class <category>accessing</category>
asn1TypeName "Answer the ASN.1 type for the extension value." ^#SubjectKeyIdentifier
</methods> <methods> Security.X509.SubjectKeyIdentifier class <category>private</category>
adoptValue: aByteArray ^self new initialize: aByteArray
oidString ^'2.5.29.14'
</methods> <methods> Security.X509.SubjectKeyIdentifier class <category>initialize-release</category>
initialize self initializeAsn1Types
initializeAsn1Types " SubjectKeyIdentifier ::= KeyIdentifier KeyIdentifier is defined by AuthorityKeyIdentifier as KeyIdentifier ::= OCTET STRING however to avoid ordering issues in registry initialization we'll shortcut the definition as follows. " ASN1Module OCTET_STRING: #SubjectKeyIdentifier
</methods> <methods> Security.X509.Name <category>marshaling</category>
asn1ChoiceType "We need to pretend to be a choice for marshaling purposes" ^ASN1Module find: #RDNSequence
asn1ChoiceValue "We need to pretend to be a choice for marshaling purposes" ^relativeDistinguishedName collect: [ :ava | OrderedCollection with: ava ]
encoding ^encoding
encoding: anEncoding encoding := anEncoding
_encoding ^encoding
_encoding: anEncoding type: aType encoding := anEncoding
</methods> <methods> Security.X509.Name <category>utilities</category>
asX509Name ^self
descriptionFor: oid ^OIDToDescription at: oid ifAbsent: [ oid getDottedOID ]
flushEncoding encoding := nil
oidFor: string ^OIDToDescription at: string ifAbsent: [ string asAsn1OID ]
</methods> <methods> Security.X509.Name <category>accessing</category>
add: anAssociation self at: anAssociation key put: anAssociation value
at: key ^self at: key ifAbsent: [nil]
at: key ifAbsent: block | oid | oid := key isCharacters ifTrue: [ self oidFor: key ] ifFalse: [ key asAsn1OID ]. ^(self getRDN detect: [ :ava | ava type = oid ] ifNone: [^block value]) value
at: key put: value | oid | oid := key isCharacters ifTrue: [ self oidFor: key ] ifFalse: [ key asAsn1OID ]. self getRDN add: ( AttributeValueAssertion new type: oid; value: value; yourself )
getDNBytes "return the raw bytes" ^self getEncoding fullEncoding
getEncoding ^encoding ifNil: [ | marshaler | marshaler := DERStream on: (ByteArray new: 100). marshaler marshalObject: self withType: self asn1Type. encoding := Encoding with: marshaler contents ]
getRDN "OrderedCollection containing the RDN attribute/value pairs" ^relativeDistinguishedName ifNil: [ relativeDistinguishedName := OrderedCollection new ]
</methods> <methods> Security.X509.Name <category>initialize</category>
initializeFromChoice: anAsn1Wrapper "The ASN.1 framework can only map SEQUENCE and SET to Smalltalk class so far, so this method helps to work around the limitation." encoding := anAsn1Wrapper _encoding. relativeDistinguishedName := OrderedCollection new. anAsn1Wrapper _value do: [ :rdn | rdn do: [ :ava | relativeDistinguishedName add: ava ] ]
</methods> <methods> Security.X509.Name <category>printing</category>
printOpenSSLOn: aStream indent: level "This should print the certificate in the format used by OpenSSL" aStream tab: level. self getRDN do: [ :ava | aStream nextPutAll: (OIDToDescription at: ava type); nextPut: $=; nextPutAll: ava value ] separatedBy: [ aStream nextPutAll: ', ' ]
shortString self commonName ifNotNil: [ :cn | ^cn ]. self name ifNotNil: [ :n | ^n ]. self surname ifNotNil: [ :sn | ^self givenName ifNil: [ sn ] ifNotNil: [ :gn | gn, ' ', sn ] ]. self organizationUnit ifNotNil: [ :ou | ^ou ]. self organization ifNotNil: [ :o | ^o ]. self email ifNotNil: [ :e | ^e ]. ^self getRDN isEmpty ifTrue: [ 'empty name' ] ifFalse: [ self getRDN first value ]
</methods> <methods> Security.X509.Name <category>accessing - name components - short</category>
C ^self country
C: string self country: string
CN ^self commonName
CN: string self commonName: string
E ^self email
E: string self email: string
L ^self locality
L: string self locality: string
N ^self name
N: string self name: string
O ^self organization
O: string self organization: string
OU ^self organizationUnit
OU: string self organizationUnit: string
S ^self state
S: string self state: string
</methods> <methods> Security.X509.Name <category>ssl</category>
asAssociations "Return an ordered collection of associations. It compares better than the dictionary an I am still not sure if the order is relevant or not. Dictionary is handy for other cases." ^self getRDN collect: [ :ava || oid | oid := ava type. (self descriptionFor: oid) -> ava value ].
asDictionary | dict | dict := Dictionary new. self getRDN do: [ :ava || oid | oid := ava type. dict at: (self descriptionFor: oid) put: ava value ]. ^dict
</methods> <methods> Security.X509.Name <category>accessing - name components</category>
commonName ^self at: 'CN'
commonName: string self at: 'CN' put: string
country ^self at: 'C'
country: string self at: 'C' put: string
description ^self at: 'D'
description: string self at: 'D' put: string
email ^self at: 'E'
email: string self at: 'E' put: string
givenName ^self at: 'GN'
givenName: string self at: 'GN' put: string
locality ^self at: 'L'
locality: string self at: 'L' put: string
name ^self at: 'N'
name: string self at: 'N' put: string
organization ^self at: 'O'
organization: string self at: 'O' put: string
organizationUnit ^self at: 'OU'
organizationUnit: string self at: 'OU' put: string
state ^self at: 'S'
state: string self at: 'S' put: string
streetAddress ^self at: 'A'
streetAddress: string self at: 'A' put: string
surname ^self at: 'SN'
surname: string self at: 'SN' put: string
</methods> <methods> Security.X509.Name class <category>accessing</category>
asn1TypeName ^#Name
</methods> <methods> Security.X509.Name class <category>initialize-release</category>
initialize self initializeAsn1Types; initializeSMINodes
initializeAsn1Types " RelativeDistinguishedName ::= SET OF AttributeTypeAndValue " ASN1Module SET: #RelativeDistinguishedName OF: #AttributeTypeAndValue. " RDNSequence ::= SEQUENCE OF RelativeDistinguishedName " ASN1Module SEQUENCE: #RDNSequence OF: #RelativeDistinguishedName. " Name ::= CHOICE { RDNSequence } " (ASN1Module CHOICE: self asn1TypeName) addElement: nil type: #RDNSequence; "mapping: self; not supported yet" retainEncoding: true; "this is the default, but to make it resilient when the default is changed" useChoice: true
initializeSMINodes "Add OIDs defined by RFC#3280: Appendix A. Psuedo-ASN.1 Structures and OIDs" SMINode root " -- suggested naming attributes: Definition of the following -- information object set may be augmented to meet local -- requirements. Note that deleting members of the set may -- prevent interoperability with conforming implementations. -- presented in pairs: the AttributeType followed by the -- type definition for the corresponding AttributeValue --Arc for standard naming attributes " atPath: #( 2 5 4 ) setSymbol: 'at'; " -- Naming attributes of type X520name X520name ::= CHOICE { teletexString TeletexString (SIZE (1..ub-name)), printableString PrintableString (SIZE (1..ub-name)), universalString UniversalString (SIZE (1..ub-name)), utf8String UTF8String (SIZE (1..ub-name)), bmpString BMPString (SIZE (1..ub-name)) } ub-name INTEGER ::= 32768 id-at-name AttributeType ::= { id-at 41 } id-at-surname AttributeType ::= { id-at 4 } id-at-givenName AttributeType ::= { id-at 42 } id-at-initials AttributeType ::= { id-at 43 } id-at-generationQualifier AttributeType ::= { id-at 44 } " atPath: #( 2 5 4 4 ) setSymbol: 'surname'; atPath: #( 2 5 4 41 ) setSymbol: 'name'; atPath: #( 2 5 4 42 ) setSymbol: 'givenName'; atPath: #( 2 5 4 43 ) setSymbol: 'initials'; atPath: #( 2 5 4 44 ) setSymbol: 'generationQualifier'; " -- Naming attributes of type X520CommonName X520CommonName ::= CHOICE { teletexString TeletexString (SIZE (1..ub-common-name)), printableString PrintableString (SIZE (1..ub-common-name)), universalString UniversalString (SIZE (1..ub-common-name)), utf8String UTF8String (SIZE (1..ub-common-name)), bmpString BMPString (SIZE (1..ub-common-name)) } ub-common-name INTEGER ::= 64 id-at-commonName AttributeType ::= { id-at 3 } " atPath: #( 2 5 4 3 ) setSymbol: 'commonName'; " -- Naming attributes of type X520LocalityName X520LocalityName ::= CHOICE { teletexString TeletexString (SIZE (1..ub-locality-name)), printableString PrintableString (SIZE (1..ub-locality-name)), universalString UniversalString (SIZE (1..ub-locality-name)), utf8String UTF8String (SIZE (1..ub-locality-name)), bmpString BMPString (SIZE (1..ub-locality-name)) } ub-locality-name INTEGER ::= 128 id-at-localityName AttributeType ::= { id-at 7 } " atPath: #( 2 5 4 7 ) setSymbol: 'localityName'; " -- Naming attributes of type X520StateOrProvinceName X520StateOrProvinceName ::= CHOICE { teletexString TeletexString (SIZE (1..ub-state-name)), printableString PrintableString (SIZE (1..ub-state-name)), universalString UniversalString (SIZE (1..ub-state-name)), utf8String UTF8String (SIZE (1..ub-state-name)), bmpString BMPString (SIZE(1..ub-state-name)) } ub-state-name INTEGER ::= 128 id-at-stateOrProvinceName AttributeType ::= { id-at 8 } " atPath: #( 2 5 4 8 ) setSymbol: 'stateOrProvinceName'; " -- Naming attributes of type X520OrganizationName X520OrganizationName ::= CHOICE { teletexString TeletexString (SIZE (1..ub-organization-name)), printableString PrintableString (SIZE (1..ub-organization-name)), universalString UniversalString (SIZE (1..ub-organization-name)), utf8String UTF8String (SIZE (1..ub-organization-name)), bmpString BMPString (SIZE (1..ub-organization-name)) } ub-organization-name INTEGER ::= 64 id-at-organizationName AttributeType ::= { id-at 10 } " atPath: #( 2 5 4 10 ) setSymbol: 'organizationName'; " -- Naming attributes of type X520OrganizationalUnitName X520OrganizationalUnitName ::= CHOICE { teletexString TeletexString (SIZE (1..ub-organizational-unit-name)), printableString PrintableString (SIZE (1..ub-organizational-unit-name)), universalString UniversalString (SIZE (1..ub-organizational-unit-name)), utf8String UTF8String (SIZE (1..ub-organizational-unit-name)), bmpString BMPString (SIZE (1..ub-organizational-unit-name)) } ub-organizational-unit-name INTEGER ::= 64 id-at-organizationalUnitName AttributeType ::= { id-at 11 } " atPath: #( 2 5 4 11 ) setSymbol: 'organizationalUnitName'; " -- Naming attributes of type X520Title X520Title ::= CHOICE { teletexString TeletexString (SIZE (1..ub-title)), printableString PrintableString (SIZE (1..ub-title)), universalString UniversalString (SIZE (1..ub-title)), utf8String UTF8String (SIZE (1..ub-title)), bmpString BMPString (SIZE (1..ub-title)) } ub-title INTEGER ::= 64 id-at-title AttributeType ::= { id-at 12 } " atPath: #( 2 5 4 12 ) setSymbol: 'title'; " -- Naming attributes of type X520dnQualifier X520dnQualifier ::= PrintableString id-at-dnQualifier AttributeType ::= { id-at 46 } " atPath: #( 2 5 4 46 ) setSymbol: 'dnQualifier'; " -- Naming attributes of type X520countryName (digraph from IS 3166) X520countryName ::= PrintableString (SIZE (2)) id-at-countryName AttributeType ::= { id-at 6 } " atPath: #( 2 5 4 6 ) setSymbol: 'countryName'; " -- Naming attributes of type X520SerialNumber X520SerialNumber ::= PrintableString (SIZE (1..ub-serial-number)) ub-serial-number INTEGER ::= 64 id-at-serialNumber AttributeType ::= { id-at 5 } " atPath: #( 2 5 4 5 ) setSymbol: 'serialNumber'; " -- Naming attributes of type X520Pseudonym X520Pseudonym ::= CHOICE { teletexString TeletexString (SIZE (1..ub-pseudonym)), printableString PrintableString (SIZE (1..ub-pseudonym)), universalString UniversalString (SIZE (1..ub-pseudonym)), utf8String UTF8String (SIZE (1..ub-pseudonym)), bmpString BMPString (SIZE (1..ub-pseudonym)) } ub-pseudonym INTEGER ::= 128 id-at-pseudonym AttributeType ::= { id-at 65 } " atPath: #( 2 5 4 65 ) setSymbol: 'pseudonym'; " -- Naming attributes of type DomainComponent (from RFC 2247) DomainComponent ::= IA5String id-domainComponent AttributeType ::= { 0 9 2342 19200300 100 1 25 } " atPath: #( 0 9 2342 19200300 100 1 25 ) setSymbol: #domainComponent; " -- Legacy attributes EmailAddress ::= IA5String (SIZE (1..ub-emailaddress-length)) ub-emailaddress-length INTEGER ::= 128 pkcs-9 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) 9 } id-emailAddress AttributeType ::= { pkcs-9 1 } " atPath: #( 1 2 840 113549 1 9) setSymbol: 'emailAddress'; atPath: #( 2 5 4 9 ) setSymbol: 'streetAddress'; atPath: #( 2 5 4 13 ) setSymbol: 'description'; yourself
</methods> <methods> Security.X509.Name class <category>ssl</category>
buildOIDToDescription | map | map := Dictionary new at: (ObjectIdentifier value: #(2 5 4 10)) put: 'O'; "organization" at: (ObjectIdentifier value: #(2 5 4 11)) put: 'OU'; "organization unit" at: (ObjectIdentifier value: #(2 5 4 3)) put: 'CN'; "common name" at: (ObjectIdentifier value: #(2 5 4 6)) put: 'C'; "country" at: (ObjectIdentifier value: #(2 5 4 7)) put: 'L'; "locality" at: (ObjectIdentifier value: #(2 5 4 8)) put: 'S'; "state or province" at: (ObjectIdentifier value: #(2 5 4 9)) put: 'A'; "streetAddress" at: (ObjectIdentifier value: #(2 5 4 4)) put: 'SN'; "surname" at: (ObjectIdentifier value: #(2 5 4 41)) put: 'N'; "name" at: (ObjectIdentifier value: #(2 5 4 42)) put: 'GN'; "givenName" at: (ObjectIdentifier value: #(2 5 4 13)) put: 'D'; "description" at: (ObjectIdentifier value: #(1 2 840 113549 1 9)) put: 'E'; "email" yourself. map keys do: [ :oid | map at: (map at: oid) put: oid ]. ^map
</methods> <methods> Security.X509.Name class <category>instance creation</category>
fromChoice: anAsn1Choice "The ASN.1 framework can only map SEQUENCE and SET to Smalltalk class so far, so this method helps to work around the limitation." ^self new initializeFromChoice: anAsn1Choice
readFrom: stream "Decode an instance of the receiver from the <stream>. stream <ReadStream> readable binary stream " ^(self fromChoice: (super readFrom: stream))
</methods> <methods> Security.X509.X509Registry <category>accessing</category>
beStrict strict := true
dontBeStrict strict := false
isStrict ^strict
</methods> <methods> Security.X509.X509Registry <category>deprecated</category>
addCertificate: aCertificate "As this is now ambiguous, we're deprecating this method in favor of #addTrusted: and addRevoked:." self addTrusted: aCertificate
addCertificates: aCollection "As this is now ambiguous, we're deprecating this method in favor of #addTrusted: and addRevoked:." aCollection do: [ :cert | self addCertificate: cert ]
certificateFor: aDNAssociations "This method is borderline ridiculous. An exact match of DN associations? How useful is that?" ^trustedCertificates detect: [ :cert | aDNAssociations = cert subject asAssociations ] ifNone: [ nil ]
removeCertificate: aCertificate "As this is now ambiguous, we're deprecating this method in favor of #removeTrusted: and #removeRevoked:." self removeTrusted: aCertificate
trustedCertificates: aSet "This is way too intrusive. Will be phased out in subsequent releases. Don't use!" trustedCertificates := aSet
</methods> <methods> Security.X509.X509Registry <category>private</category>
brokenChain: subject issuer: issuer ^BrokenChain new messageText: (#CertificateChainInvalid << #security >> 'Certificate Chain Invalid !'); parameter: (Array with: subject with: issuer); isResumable: true; yourself
certificateExpired: aCertificate ^Expired new messageText: (#CertificateExpired << #security >> 'Certificate expired!'); parameter: aCertificate; isResumable: true; raiseSignal
certificateNotValidYet: aCertificate ^NotValidYet new messageText: (#CertificateNotValidYet << #security >> 'Certificate not valid yet!'); parameter: aCertificate; isResumable: true; raiseSignal
prepareForValidation: chain "Prepare a certificate chain for validation loop. chain <OrderedCollection of: Certificate> ^<OrderedCollection of: Certificate> " ^(self trustedCertificateMatching: chain last subjectDNInBytes) ifNil: [ (self trustedCertificateMatching: chain last issuerDNInBytes) "In this case either the chain is rooted in an unknown CA certificate, or the chain is simply incomplete. Both cases are equally bad." ifNil: [ self rootNotTrusted: chain. "If the exception is explicitly resumed, we'll let validation to continue." chain ] "Since the self signed certificate at the end of the chain is practically useless, it is common practice to simply not send it. In this case just add our trusted CA cert to the end of the chain" ifNotNil: [ :trusted | chain copyWith: trusted ] ] "This is the standard case, only the local copy of the trusted certificate should be used to validate the root of the chain" ifNotNil: [ :trusted | chain copy removeLast; addLast: trusted; yourself ].
rootNotTrusted: chain ^RootNotTrusted new messageText: (#CANotInTrustRegistry << #security >> 'CA Not in Trust Registry!'); parameter: chain last; isResumable: true; raiseSignal
trustedCertificateMatching: dnBytes ^trustedCertificates detect: [ :cert | dnBytes = cert subjectDNInBytes ] ifNone: [ nil ]
</methods> <methods> Security.X509.X509Registry <category>accessing - trusted</category>
addTrusted: aCertificate "Add trusted CA certificate to the registry." self verifyCACertificate: aCertificate. trustedCertificates add: aCertificate
removeTrusted: aCertificate trustedCertificates remove: aCertificate
trustedCertificates ^trustedCertificates
trustedSubject: criteria "Return a trusted certificate with subject name matching criteria criteria <BlockClosure> a one argument selection block that will receive the subject Name as the argument ^<Certificate> " ^self trustedCertificates detect: [ :cert | criteria value: cert subject ] ifNone: [ nil ]
</methods> <methods> Security.X509.X509Registry <category>accessing - revoked</category>
addRevoked: aCertificate revokedCertificates add: aCertificate
removeRevoked: aCertificate revokedCertificates remove: aCertificate
revokedCertificates ^revokedCertificates
revokedSubject: criteria "Return a revoked certificate with subject name matching criteria. criteria <BlockClosure> a one argument selection block that will receive the subject Name as the argument ^<Certificate> " ^self revokedCertificates detect: [ :cert | criteria value: cert subject ] ifNone: [ nil ]
</methods> <methods> Security.X509.X509Registry <category>initialize-release</category>
initialize strict := self class shouldBeStrict. trustedCertificates := Set new. revokedCertificates := Set new
</methods> <methods> Security.X509.X509Registry <category>chain verification</category>
validateCertificateChain: chain "This is the main entry point for certificate chain validation. The chain is expected to be ordered in the ascending order of the subject issuer relationship, i.e. subject before its issuer. This method performs all the necessary checks and raises an exception if any check fails. The exceptions are resumable so it is possible to collect a list of all problems that the chain has and present them at once. If the chain passes validation the method completes without exceptions. chain <OrderedCollection of: Certificate> " (self prepareForValidation: chain) inject: nil into: [ :subject :issuer | self verifyRevocationStatus: issuer; verifyValidityPeriod: issuer; verifyCriticalExtentions: issuer. subject ifNotNil: [ self verifyCACertificate: issuer; verify: subject isIssuedBy: issuer ]. issuer ]
verify: subject isIssuedBy: issuer [ subject verifyIssuedBy: issuer ] on: IssuerMismatch do: [ :ex | ex resignalAs: (self brokenChain: subject issuer: issuer) ]
verifyBasicConstraints: certificate "Verify that a supposedly CA certificate has a properly set up BasicConstraints extension. Signal an error if there's a problem. " | basicConstraints | basicConstraints := certificate basicConstraints. basicConstraints isNil ifTrue: [ ^BadCAConstraints new messageText: (#MissingBasicConstraints << #security >> 'Basic Constraints are required for a CA certificate !'); parameter: certificate; raiseSignal ]. basicConstraints isCritical ifFalse: [ ExtensionShouldBeCritical new messageText: (#ExtShouldBeCritical << #security >> 'This extension should be critical'); parameter: certificate; extension: basicConstraints; raiseSignal ]. basicConstraints ca ifFalse: [ BadCAConstraints new messageText: (#NonCABasicConstraints << #security >> 'Basic Constraints are invalid for a CA certificate !'); parameter: certificate; raiseSignal ].
verifyCACertificate: certificate "Verify that certificate is properly marked as a CA certificate. Signal an error if there's a problem. " "Unfortunatelly V1 certificates are still widely deployed (e.g. Verisign), so we'll allow V1 roots when in relaxed mode" ( self isStrict not and: [certificate subjectDNInBytes = certificate issuerDNInBytes and: [certificate isVersionOne]] ) ifTrue: [^self]. self verifyBasicConstraints: certificate; verifyKeyUsage: certificate
verifyCriticalExtentions: certificate "Verify that all critical extensions of certificate are properly handled. Signal an error if there's a problem. " ( certificate criticalExtensions detect:[ :ext | ext isHandled not] ifNone:[ nil ] ) ifNotNil: [ :extension | UnhandledCriticalExtension new messageText: (#UnhandledCriticalExt << #security >> 'Critical extension is not handled'); parameter: certificate; extension: extension; raiseSignal ].
verifyKeyUsage: certificate "Verify that a supposedly CA certificate has a properly set up KeyUsage extension. Signal an error if there's a problem. " | keyUsage | keyUsage := certificate keyUsage. keyUsage isNil ifTrue: [ ^self isStrict ifTrue: [ BadCAKeyUsage new messageText: (#MissingKeyUsage << #security >> 'Key Usage is required for a CA certificate !'); parameter: certificate; raiseSignal ] ]. keyUsage isCritical ifFalse:[ ExtensionShouldBeCritical new messageText: (#ExtShouldBeCritical << #security >> 'This extension should be critical'); parameter: certificate; extension: keyUsage; raiseSignal ]. keyUsage keyCertSign ifFalse: [ BadCAKeyUsage new messageText: (#NotForCertSigning1 << #security >> 'Key Usage is invalid for a CA certificate !'); parameter: certificate; raiseSignal ].
verifyRevocationStatus: certificate "Verify that a certificate was not revoked. Signal an error if there's a problem. " (revokedCertificates anySatisfy: [ :revoked | certificate isSameAs: revoked ]) ifTrue: [ Revoked new messageText: ( #CertificateRevoked << #security >> 'Certificate for <1s> is revoked!' expandMacrosWith: certificate subject shortString); parameter: certificate; raiseSignal ]
verifyValidityPeriod: certificate "Verify that certificate is within its validity period. Otherwise signal an error. " certificate isNotValidYet ifTrue: [ self certificateNotValidYet: certificate ]. certificate isExpired ifTrue: [ self certificateExpired: certificate ]
</methods> <methods> Security.X509.X509Registry class <category>instance creation</category>
default ^default isNil ifTrue:[default := self newDefault ] ifFalse:[default ]
new ^super new initialize
newDefault ^self newFromDefaultCertificateFile
newFromCertificateFile: aFileString | registry defaultFile | registry := self new. defaultFile := aFileString asFilename. defaultFile exists ifTrue: [ (CertificateFileReader readFromFile: defaultFile) do: [ :certificate | registry addTrusted: certificate ] ]. ^registry
newFromDefaultCertificateFile ^self newFromCertificateFile: self defaultCertificateFile asFilename
</methods> <methods> Security.X509.X509Registry class <category>accessing</category>
addCertificateToTrust: aCertificate self trustedCertificates add: aCertificate. self updateDictionaries
beStrict ShouldBeStrict := true.
defaultCertificateFile ^DefaultCertificateFile isNil ifTrue:[DefaultCertificateFile := 'trustedCertificates.pem'] ifFalse:[ DefaultCertificateFile]
defaultCertificateFile: aString DefaultCertificateFile := aString
dontBeStrict ShouldBeStrict := false.
removeCertificate: aCertificate "remove a trusted Certificate from the registry and update the indexes" self trustedCertificates remove: aCertificate ifAbsent: []. self updateDictionaries
shouldBeStrict ^ShouldBeStrict
trustedCertificates ^self default trustedCertificates
</methods> <methods> Security.X509.X509Registry class <category>testing</category>
trustedCertificatesContains: aCertificate "fix this to add the certificate search" ^self trustedCertificates contains: aCertificate
</methods> <methods> Security.X509.X509Registry class <category>deprecated</category>
readTrustedCertificatesFromFile: aFilename "self readTrustedCertificatesFromFile: '..\..\demo.pem'" | collection | collection := CertificateFileReader readCertificatesFrom: aFilename. self trustedCertificates addAll: collection.
</methods> <methods> Security.X509.X509Registry class <category>private</category>
updateDictionaries " needs to be added. update our indexes. want to index by signature, subjectDN"
</methods> <methods> Security.X509.DSSParameters <category>accessing</category>
g ^g
getg ^g
getp ^p
getq ^q
p ^p
q ^q
</methods> <methods> Security.X509.DSSParameters <category>initialize</category>
p: aP q: aQ g: aG p := aP. q := aQ. g := aG
</methods> <methods> Security.X509.DSSParameters <category>marshaling</category>
encodeASN1With: aMarshaler self asn1Type encodeValue: self with: aMarshaler
tagBER "... avoid the namespace lookup." ^02r00110000 "ASN1.ConstructedSEQUENCE = 48"
</methods> <methods> Security.X509.DSSParameters class <category>accessing</category>
asn1TypeName ^#'Dss-Parms'
</methods> <methods> Security.X509.DSSParameters class <category>initialize-release</category>
initialize self initializeAsn1Types
initializeAsn1Types " Dss-Parms ::= SEQUENCE { p INTEGER, q INTEGER, g INTEGER } " ( ASN1Module SEQUENCE: self asn1TypeName) addElement: #p type: #INTEGER; addElement: #q type: #INTEGER; addElement: #g type: #INTEGER; mapping: self
</methods> <methods> Security.X509.DSSParameters class <category>instance creation</category>
p: aP q: aQ g: aG ^self new p: aP q: aQ g: aG
</methods> <methods> Security.X509.KeyUsage <category>accessing</category>
bits ^bits
crlSign "Assert/Deny that subject's key can be used for verifying a signature on certificate revocation list (e.g., a CRL, delta CRL, or an ARL)." ^bits bitAt: 7
crlSign: aBoolean "Assert/Deny that subject's key can be used for verifying a signature on certificate revocation list (e.g., a CRL, delta CRL, or an ARL)." bits bitAt: 7 put: aBoolean
dataEncipherment "Assert/Deny that subject's key is used for enciphering user data, other than cryptographic keys." ^bits bitAt: 4
dataEncipherment: aBoolean "Assert/Deny that subject's key is used for enciphering user data, other than cryptographic keys." bits bitAt: 4 put: aBoolean
decipherOnly "Assert/Deny that subject's key may be used only for deciphering data while performing key agreement (keyAgreement must be true)." ^bits bitAt: 9
decipherOnly: aBoolean "Assert/Deny that subject's key may be used only for deciphering data while performing key agreement (keyAgreement must be true). RFC#3279 (section 2.3.3 Diffie-Hellman Key Exchange Keys): If the keyUsage extension is present in a certificate which conveys a DH public key, the following values may be present: keyAgreement; encipherOnly; and decipherOnly. If present, the keyUsage extension MUST assert keyAgreement and MAY assert either encipherOnly and decipherOnly. The keyUsage extension MUST NOT assert both encipherOnly and decipherOnly." aBoolean ifTrue: [ self setKeyAgreement. self encipherOnly: false ]. bits bitAt: 9 put: aBoolean
denyAll bits clearAllBits
digitalSignature "Assert/Deny that subject's key can be used for signing anything but certificates and CRLs." ^bits bitAt: 1
digitalSignature: aBoolean "Assert/Deny that subject's key can be used for signing anything but certificates and CRLs." bits bitAt: 1 put: aBoolean
encipherOnly "Assert/Deny that subject's key may be used only for enciphering data while performing key agreement (keyAgreement must be true)." ^bits bitAt: 8
encipherOnly: aBoolean "Assert/Deny that subject's key may be used only for enciphering data while performing key agreement (keyAgreement must be true). RFC#3279 (section 2.3.3 Diffie-Hellman Key Exchange Keys): If the keyUsage extension is present in a certificate which conveys a DH public key, the following values may be present: keyAgreement; encipherOnly; and decipherOnly. If present, the keyUsage extension MUST assert keyAgreement and MAY assert either encipherOnly and decipherOnly. The keyUsage extension MUST NOT assert both encipherOnly and decipherOnly." aBoolean ifTrue: [ self setKeyAgreement. self decipherOnly: false ]. bits bitAt: 8 put: aBoolean.
keyAgreement "Assert/Deny that the subject's key can be used for key agreement (e.g. Diffie-Hellman)." ^bits bitAt: 5
keyAgreement: aBoolean "Assert/Deny that the subject's key can be used for key agreement (e.g. Diffie-Hellman). RFC#3279 (section 2.3.3 Diffie-Hellman Key Exchange Keys): If the keyUsage extension is present in a certificate which conveys a DH public key, the following values may be present: keyAgreement; encipherOnly; and decipherOnly. If present, the keyUsage extension MUST assert keyAgreement and MAY assert either encipherOnly and decipherOnly. The keyUsage extension MUST NOT assert both encipherOnly and decipherOnly." bits bitAt: 5 put: aBoolean. self clearEncipherDecipherOnly
keyCertSign "Assert/Deny that subject's key can be used for verifying a signature on public key certificates." ^bits bitAt: 6
keyCertSign: aBoolean "Assert/Deny that subject's key can be used for verifying a signature on public key certificates." bits bitAt: 6 put: aBoolean
keyEncipherment "Assert/Deny that the subject's key can be used for key transport" ^bits bitAt: 3
keyEncipherment: aBoolean "Assert/Deny that the subject's key can be used for key transport" bits bitAt: 3 put: aBoolean
nonRepudiation "Assert/Deny that the subject's key can be used for non-repudiation signatures, excluding certificate or CRL signing." ^bits bitAt: 2
nonRepudiation: aBoolean "Assert/Deny that the subject's key can be used for non-repudiation signatures, excluding certificate or CRL signing." bits bitAt: 2 put: aBoolean
</methods> <methods> Security.X509.KeyUsage <category>initialize-release</category>
initialize super initialize. self initialize: ( BitString unused: 7 bytes: (ByteArray new: 2) )
initialize: aBitString bits := aBitString
</methods> <methods> Security.X509.KeyUsage <category>testing</category>
isHandled ^true
isKeyUsage ^true
shouldBeCritical ^true
</methods> <methods> Security.X509.KeyUsage <category>private</category>
clearEncipherDecipherOnly bits bitAt: 8 put: false; bitAt: 9 put: false
setKeyAgreement bits bitAt: 5 put: true
</methods> <methods> Security.X509.KeyUsage <category>marshaling</category>
asn1Value ^self bits
</methods> <methods> Security.X509.KeyUsage <category>printing</category>
printOpenSSLOn: aStream indent: level "This should print the extension in the format used by OpenSSL" | set titles | aStream cr; tab: level; nextPutAll: (#KeyUsagePrefix << #security >> 'X509v3 Key Usage:') asString. critical ifTrue: [aStream nextPutAll: (#CriticalSuffix << #security >> ' critical') asString ]. titles := #( 'Digital Signature' 'Non Repudiation' 'Key Encipherment' 'Encryption' 'Key Agreement' 'Certificate Sign' 'CRL Sign' 'Encipher Only' 'Decipher Only'). set := (1 to: 9) select: [ :i | bits bitAt: i ]. aStream cr; tab: level + 1. set do: [ :i | aStream nextPutAll: (titles at: i) ] separatedBy: [ aStream nextPutAll: ', ' ]
</methods> <methods> Security.X509.KeyUsage class <category>initialize-release</category>
initialize self initializeAsn1Types
initializeAsn1Types " KeyUsage ::= BIT STRING { digitalSignature (0), nonRepudiation (1), keyEncipherment (2), dataEncipherment (3), keyAgreement (4), keyCertSign (5), cRLSign (6), encipherOnly (7), decipherOnly (8) } " ASN1Module BIT_STRING: #KeyUsage
</methods> <methods> Security.X509.KeyUsage class <category>accessing</category>
asn1TypeName "Answer the ASN.1 type for the extension value." ^#KeyUsage
</methods> <methods> Security.X509.KeyUsage class <category>private</category>
adoptValue: aBitString ^self new initialize: aBitString
oidString ^'2.5.29.15'
</methods> <methods> Security.X509.TBSCertificate <category>accessing - key usage</category>
forCertificateSigning "Mark the certificate as suitable for signing other certificates." self forCertificateSigning: nil
forCertificateSigning: depth "Mark the certificate as suitable for signing other certificates. depth <Integer> what is the maximum length of valid certificate chain with this certificate as root" self getEmptyKeyUsage keyCertSign: true. self getBasicConstraints ca: true; depth: depth
forCRLSigning "Mark the certificate as suitable for signing CRLs." self getEmptyKeyUsage crlSign: true.
forEncryption "Mark this certificate as suitable for encryption of data." self subjectPublicKeyInfo publicKey assertEncryptionIn: self
forKeyExchange "Mark this certificate as suitable for key exchange or key agreement depending on the key algorithm" self subjectPublicKeyInfo publicKey assertKeyExchangeIn: self
forSigning "Mark this certificate as suitable for signing anything except certificates and CRLs" self subjectPublicKeyInfo publicKey assertSigningIn: self
</methods> <methods> Security.X509.TBSCertificate <category>accessing - extensions - key usage</category>
getEmptyKeyUsage ^(self getExtension: KeyUsage) denyAll; yourself
hasKeyUsage ^self keyUsage notNil
isCrlSign ^self keyUsage ifNil: [false] ifNotNil: [ :ku | ku crlSign ]
isDataEncipherment ^self keyUsage ifNil: [false] ifNotNil: [ :ku | ku dataEncipherment ]
isDecipherOnly ^self keyUsage ifNil: [ false ] ifNotNil: [ :ku | ku decipherOnly ]
isDigitalSignature ^self keyUsage ifNil: [ false ] ifNotNil: [ :ku | ku digitalSignature ]
isEncipherOnly ^self keyUsage ifNil: [ false ] ifNotNil: [ :ku | ku encipherOnly ]
isKeyAgreement ^self keyUsage ifNil: [ false ] ifNotNil: [ :ku | ku keyAgreement ]
isKeyCertSign ^self keyUsage ifNil: [ false ] ifNotNil: [ :ku | ku keyCertSign ]
isKeyEncipherment ^self keyUsage ifNil: [ false ] ifNotNil: [ :ku | ku keyEncipherment ]
isNonRepudiation ^self keyUsage ifNil: [ false ] ifNotNil: [ :ku | ku nonRepudiation ]
keyUsage ^self extension: [ :ext | ext isKeyUsage ] ifAbsent: [nil]
</methods> <methods> Security.X509.TBSCertificate <category>accessing - extensions</category>
addExtension: anExtension self supportsExtensions ifFalse: [ ^NoExtensionSupport raiseWith: self ]. ^self extensions add: anExtension
criticalExtensions ^self extensions select:[:ea | ea isCritical]
extension: detectionBlock ifAbsent: notFoundBlock ^self extensions detect: detectionBlock ifNone: notFoundBlock
extensions ^extensions ifNil: [ self supportsExtensions ifTrue: [ extensions := OrderedCollection new ] ifFalse: [ #() ] ]
getExtension: extensionClass "Find or create an extension of specified class." ^self extension: [ :ext | ext class = extensionClass ] ifAbsent: [ self addExtension: extensionClass new ]
hasExtensions ^self extensions notEmpty
supportsExtensions ^self versionName > 2
</methods> <methods> Security.X509.TBSCertificate <category>accessing</category>
serialNumber "serial number of this certificate" ^serialNumber
signatureAlgorithm ^signature
signatureAlgorithm: anAlgorithmIdentifier signature := anAlgorithmIdentifier. self encoding: nil.
signatureAlgorithmOID "OID of the algorithm used to sign this certificate" ^signature getOID
signatureAlgorithmOIDDescription "description of the OID of the algorithm used to sign this certificate" ^signature getOIDDescription
versionName ^version ifNil: [ version := 3 ]
</methods> <methods> Security.X509.TBSCertificate <category>accessing - subject</category>
subject ^subject
subjectDN "distinguished name of the subject" ^subject getRDN
subjectDNInBytes "distinguished name of the subject" ^subject getDNBytes
subjectUniqueID ^subjectUniqueID
</methods> <methods> Security.X509.TBSCertificate <category>accessing - validity</category>
isExpired ^validity isExpired
isNotValidYet ^validity isNotValidYet
isValid ^validity isValid
isValidOn: time ^validity isValidOn: time
notAfter ^validity notAfterTimestamp
notAfter: aTimestamp self validity notAfterTimestamp: aTimestamp asTimestamp. self encoding: nil
notAfterDate "instance of Date containing the date component of notAfter" ^validity notAfterDate
notAfterTime "instance of Time containing the time component of notAfter" ^validity notAfterTime
notBefore ^validity notBeforeTimestamp
notBefore: aTimestamp self validity notBeforeTimestamp: aTimestamp asTimestamp. self encoding: nil
notBeforeDate "instance of Date containing the date component of notBefore" ^validity notBeforeDate
notBeforeTime "instance of Time containing the time component of notBefore" ^validity notBeforeTime
</methods> <methods> Security.X509.TBSCertificate <category>marshaling</category>
encoding: anEncoding encoding := anEncoding
extensions: aCollection extensions := aCollection
issuer: aName "The ASN.1 framework can only map SEQUENCE and SET to Smalltalk class so far, so this just works around the limitation." issuer := aName asX509Name
issuerUniqueID: aBitString issuerUniqueID := aBitString
serialNumber: anInteger serialNumber := anInteger
signature ^signature
signature: anAlgorithmIdentifier signature := anAlgorithmIdentifier
subject: aName "The ASN.1 framework can only map SEQUENCE and SET to Smalltalk class so far, so this just works around the limitation." subject := aName asX509Name
subjectPublicKeyInfo: aKeyInfo subjectPublicKeyInfo := aKeyInfo
subjectUniqueID: aBitString subjectUniqueID := aBitString
validity ^validity ifNil: [ validity := Validity new ]
validity: aValidity validity := aValidity
version ^self versionName - 1
version: anInteger version := anInteger + 1
_encoding ^encoding
_encoding: anEncoding type: aType encoding := anEncoding
</methods> <methods> Security.X509.TBSCertificate <category>accessing - key</category>
publicKey ^self subjectPublicKeyInfo getPublicKey
publicKey: aPublicKey self encoding: nil. self subjectPublicKeyInfo publicKey: aPublicKey. self supportsExtensions ifTrue: [ self subjectPublicKeyInfo publicKey assertDefaultUsageIn: self ]
subjectPublicKeyInfo "subject's public key info" ^subjectPublicKeyInfo ifNil: [ subjectPublicKeyInfo := SubjectPublicKeyInfo new ]
</methods> <methods> Security.X509.TBSCertificate <category>accessing - issuer</category>
issuer ^issuer
issuerDN "distinguished name of the issuer" ^issuer getRDN
issuerDNInBytes "distinguished name of the issuer" ^issuer getDNBytes
issuerUniqueID ^issuerUniqueID
</methods> <methods> Security.X509.TBSCertificate <category>utilities</category>
flushEncoding self encoding: nil. issuer flushEncoding. subject flushEncoding.
</methods> <methods> Security.X509.TBSCertificate <category>accessing - internals</category>
derCertificate ^self getEncoding fullEncoding
encoding ^encoding
getEncoding ^encoding ifNil: [ | marshaler | marshaler := DERStream on: (ByteArray new: 100). marshaler marshalObject: self withType: self asn1Type. encoding := Encoding with: marshaler contents ]
</methods> <methods> Security.X509.TBSCertificate <category>accessing - extensions - basic constraints</category>
basicConstraints ^self extension: [ :ext | ext isBasicConstraints ] ifAbsent: [nil]
getBasicConstraints ^self getExtension: BasicConstraints
hasBasicConstraints ^self basicConstraints notNil
isCACertificate ^self basicConstraints ifNil: [ false ] ifNotNil: [ :bc | bc ca ]
</methods> <methods> Security.X509.TBSCertificate <category>printing</category>
printOpenSSLOn: aStream indent: level "This should print the certificate in the format used by OpenSSL" aStream tab: level; nextPutAll: (#VersionPrefix << #security >> 'Version: ') asString; print: self versionName; nextPutAll: ' (0x'; print: self version; nextPut: $); cr; tab: level; nextPutAll: (#SerialNumberPrefix << #security >> 'Serial Number: ') asString; cr. serialNumber asBigEndianByteArray printOpenSSLOn: aStream indent: level + 1 width: 50. aStream tab: level; nextPutAll: (#SignatureAlgorithmPrefix << #security >> 'Signature Algorithm: ') asString; nextPutAll: signature getOIDDescription; cr; tab: level; nextPutAll: (#IssuerPrefix << #security >> 'Issuer: ') asString. issuer printOpenSSLOn: aStream indent: 0. aStream cr; tab: level; nextPutAll: (#ValidityPrefix << #security >> 'Validity') asString; cr. validity printOpenSSLOn: aStream indent: level + 1. aStream cr; tab: level; nextPutAll: (#SubjectPrefix << #security >> 'Subject: ') asString. subject printOpenSSLOn: aStream indent: 0. aStream cr; tab: level; nextPutAll: (#SubjectKeyInfoPrefix << #security >> 'Subject Public Key Info:') asString; cr. subjectPublicKeyInfo printOpenSSLOn: aStream indent: level + 1. "key" (extensions isNil or: [extensions isEmpty]) ifFalse: [ aStream tab: level; nextPutAll: (#X509ExtensionsPrefix << #security >> 'X509v3 extensions:') asString. extensions do: [ :ext | ext printOpenSSLOn: aStream indent: level + 1 ] ]
</methods> <methods> Security.X509.TBSCertificate class <category>accessing</category>
asn1TypeName ^#TBSCertificate
</methods> <methods> Security.X509.TBSCertificate class <category>initialize-release</category>
initialize self initializeAsn1Types
initializeAsn1Types " TBSCertificate ::= SEQUENCE { version [0] EXPLICIT Version DEFAULT v1, serialNumber CertificateSerialNumber, signature AlgorithmIdentifier, issuer Name, validity Validity, subject Name, subjectPublicKeyInfo SubjectPublicKeyInfo, issuerUniqueID [1] IMPLICIT UniqueIdentifier OPTIONAL, -- If present, version MUST be v2 or v3 subjectUniqueID [2] IMPLICIT UniqueIdentifier OPTIONAL, -- If present, version MUST be v2 or v3 extensions [3] EXPLICIT Extensions OPTIONAL -- If present, version MUST be v3 } " ( ASN1Module SEQUENCE: self asn1TypeName ) addElement: #version type: #Version tag: 0 tagging: #explicit default: 0; addElement: #serialNumber type: #CertificateSerialNumber; addElement: #signature type: #AlgorithmIdentifier; addElement: #issuer type: #Name; addElement: #validity type: #Validity; addElement: #subject type: #Name; addElement: #subjectPublicKeyInfo type: #SubjectPublicKeyInfo; addOptionalElement: #issuerUniqueID type: #UniqueIdentifier tag: 1 tagging: #implicit; addOptionalElement: #subjectUniqueID type: #UniqueIdentifier tag: 2 tagging: #implicit; addOptionalElement: #extensions type: #Extensions tag: 3 tagging: #explicit; mapping: self; retainEncoding: true. " Version ::= INTEGER { v1(0), v2(1), v3(2) } " ( ASN1Module INTEGER: #Version ) identifiers: ( Array with: #v1 -> 0 with: #v2 -> 1 with: #v3 -> 2 ). " CertificateSerialNumber ::= INTEGER " ASN1Module INTEGER: #CertificateSerialNumber. " UniqueIdentifier ::= BIT STRING " ASN1Module BIT_STRING: #UniqueIdentifier. " Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension " ( ASN1Module SEQUENCE: #Extensions OF: #Extension ) constraint: ( SizeConstraint lower: 1 upper: SmallInteger maxVal ).
</methods> <methods> Security.X509.CertificateFileReader <category>api</category>
readFrom: aStream "Read certificates and private keys from PEM formatted stream. Raises proceedable X509Warnings on read errors. ^<OrderedCollection of: (X509Certificate | X509PrivateKey)> " | things | things := OrderedCollection new. [ aStream atEnd ] whileFalse: [ | mark chunk | aStream skipThroughAll: '-----BEGIN '. aStream atEnd ifTrue: [^things]. mark := aStream throughAll: '-----'. chunk := aStream upToAll: '-----END ', mark. aStream throughAll: '-----END ', mark. (('*private*key*' match: mark) ifTrue: [ self readKey: mark from: chunk. ] ifFalse: [ ('*certificate*' match: mark) ifTrue: [ self readCertificate: mark from: chunk ] ifFalse: [ X509Warning new messageText: ( (#UnknownPEMEntity1s << #security >> 'Unknown PEM entity <1s>') expandMacrosWith: mark); parameter: chunk; raise. nil ] ] ) ifNotNil: [ :thing | things add: thing ] ]. ^things
</methods> <methods> Security.X509.CertificateFileReader <category>private</category>
readCertificate: mark from: chunk ^[ Certificate fromBase64: chunk ] on: Error do: [ :ex | X509Warning new messageText: ( (#CertReadError1s << #security >> 'Error reading certificate <1s>') expandMacrosWith: mark); parameter: chunk; raise. nil ]
readKey: mark from: chunk ^[ (X509PrivateKey keyClassForPEM: mark) ifNil: [ X509Warning new messageText: ( (#UnknownKey1s << #security >> 'Unknown private key <1s>') expandMacrosWith: mark); parameter: chunk; raise. nil ] ifNotNil: [ :class | class fromBase64: chunk ] ] on: Error do: [ :ex | X509Warning new messageText: ( (#KeyReadError1s << #security >> 'Error reading private key <1s>') expandMacrosWith: mark); parameter: chunk; raise. nil ]
</methods> <methods> Security.X509.CertificateFileReader class <category>deprecated</category>
readCertificatesFrom: aFilename "self readCertificatesFrom: 'd:\encryptionCommon\demo.pem'" ^self readFromFile: aFilename
</methods> <methods> Security.X509.CertificateFileReader class <category>utilities</category>
readFromFile: aFilename "Read certificates and private keys from PEM formatted file self readFromFile: 'ca-bundle.crt' " | stream | stream := aFilename asFilename readStream . ^[ self new readFrom: stream ] ensure: [ stream close ]
</methods> <methods> Security.X509.X509PrivateKey <category>accessing</category>
getKey ^self subclassResponsibility
</methods> <methods> Security.X509.X509PrivateKey <category>converting</category>
asKey "Convert the X509 structure into an actual algorithm key" ^self getKey
</methods> <methods> Security.X509.X509PrivateKey class <category>utilities</category>
canReadPEM: mark ^false
keyClassForPEM: mark ^self subclasses detect: [ :c | c canReadPEM: mark ] ifNone: [ nil ]
</methods> <methods> Security.X509.X509PrivateKey class <category>private</category>
getPrivateKeyDataFrom: aPEMString "Answers the Base64 encoded Private Key if aPEMString has the appropriate delimiters required for PEM format; otherwise, answers nil" | stream mark chunk | stream := aPEMString readStream. stream skipThroughAll: '-----BEGIN '. stream atEnd ifTrue: [^nil]. mark := stream throughAll: '-----'. (self canReadPEM: mark) ifFalse: [^nil]. chunk := stream upToAll: '-----END ', mark. ^chunk
</methods> <methods> Security.X509.X509PrivateKey class <category>instance creation</category>
fromBase64: aString ^self fromBytes: (self decodeBase64: (self stripWhitespace: aString))
fromBytes: bytes | stream | stream := DERStream with: bytes. stream reset. ^stream unmarshalObjectType: self asn1Type
fromString: aString | s | s := self getPrivateKeyDataFrom: aString. s isNil ifTrue: [^nil]. ^self fromBase64: s
</methods> <methods> Security.X509.X509PublicKey <category>private</category>
assertDefaultUsageIn: aTBSCertificate aTBSCertificate forSigning
assertEncryptionIn: aTBSCertificate "Mark this certificate as suitable for encryption of data." X509Error new messageText: #X509KeyNotForEncryption << #security >> 'The key is not suitable for encryption!'; parameter: aTBSCertificate; raise
assertKeyExchangeIn: aTBSCertificate "Mark this certificate as suitable for key exchange or key agreement depending on the key algorithm" X509Error new messageText: #X509KeyNotForKeyExchange << #security >> 'The key is not suitable for key exchange!'; parameter: aTBSCertificate; raise
assertSigningIn: aTBSCertificate "Mark this certificate as suitable for signing anything except certificates and CRLs" aTBSCertificate getEmptyKeyUsage digitalSignature: true
</methods> <methods> Security.X509.X509PublicKey <category>accessing</category>
algorithmOID ^self class algorithmOID
algorithmParameters "AlgorithmIdentifier parameters for this key" ^nil
getKey ^self subclassResponsibility
</methods> <methods> Security.X509.X509PublicKey <category>converting</category>
asKey "Convert the X509 structure into an actual algorithm key" ^self getKey
</methods> <methods> Security.X509.X509PublicKey class <category>accessing</category>
algorithmOID ^algorithmOID ifNil: [ algorithmOID := ObjectIdentifier value: self algorithmOIDArray ]
algorithmOIDArray "Algorithm specific OID value as prescribed by RFC#3279, section 2.3 Subject Public Key Algorithms" ^self subclassResponsibility
keyClassFor: anAlgorithmIdentifier ^self allSubclasses detect: [ :class | anAlgorithmIdentifier algorithm = class algorithmOID ] ifNone: [ nil ]
</methods> <methods> Security.X509.X509PublicKey class <category>marshaling</category>
adoptValue: value "Some keys are simple types that the ASN.1 framework can't map to class automatically, so we need to work around that here." "by default the key is mappable so there's nothing that needs to be done; just return the value" ^value
</methods> <methods> Security.X509.X509DSAPublicKey <category>printing</category>
printOpenSSLOn: aStream indent: level "This should print the key in the format used by OpenSSL" aStream tab: level; nextPutAll: (#DSAPubKeyPrefix << #security >> 'DSA Public Key:') asString; cr; tab: level + 1; nextPutAll: (#pubPrefix << #security >> 'pub:') asString; cr. publicKey asBigEndianByteArray printOpenSSLOn: aStream indent: level + 2 width: 15. aStream tab: level + 1; nextPutAll: (#PPrefix << #security >> 'P:') asString; cr. dssParameters p asBigEndianByteArray printOpenSSLOn: aStream indent: level + 2 width: 15. aStream tab: level + 1; nextPutAll: (#QPrefix << #security >> 'Q:') asString; cr. dssParameters q asBigEndianByteArray printOpenSSLOn: aStream indent: level + 2 width: 15. aStream tab: level + 1; nextPutAll: (#GPrefix << #security >> 'G:') asString; cr. dssParameters g asBigEndianByteArray printOpenSSLOn: aStream indent: level + 2 width: 15.
</methods> <methods> Security.X509.X509DSAPublicKey <category>accessing</category>
dssParameters ^dssParameters
dssParameters: anObject dssParameters := anObject
getKey ^dssParameters notNil ifTrue:[ DSAPublicKey p: dssParameters p q: dssParameters q g: dssParameters g y: publicKey ] ifFalse:[ DSAPublicKey p: nil q: nil g: nil y: publicKey ]
publicKey ^publicKey
publicKey: anInteger publicKey := anInteger
</methods> <methods> Security.X509.X509DSAPublicKey <category>marshaling</category>
algorithmParameters "AlgorithmIdentifier parameters for this key" ^self dssParameters ifNotNil: [ :params | OrderedCollection with: params p with: params q with: params g ]
algorithmParameters: anOrderedCollection "AlgorithmIdentifier parameters for this key" ^self dssParameters: ( DSSParameters p: anOrderedCollection first q: (anOrderedCollection at: 2) g: anOrderedCollection last)
marshalingValue ^self publicKey
</methods> <methods> Security.X509.X509DSAPublicKey <category>writing</category>
writeOn: stream "Encode the receiver on the <stream>. stream <WriteStream> writable binary stream " (DERStream wrap: stream) marshalObject: self marshalingValue withType: self asn1Type
</methods> <methods> Security.X509.X509DSAPublicKey class <category>initialize-release</category>
initialize self initializeAsn1Types
initializeAsn1Types " DSAPublicKey ::= INTEGER -- public key, Y " ASN1Module INTEGER: self asn1TypeName
</methods> <methods> Security.X509.X509DSAPublicKey class <category>accessing</category>
algorithmOIDArray "RFC#3279 (section 2.3.2 DSA Signature Keys): The Digital Signature Algorithm (DSA) is defined in the Digital Signature Standard (DSS) [FIPS 186]. The DSA OID supported by this profile is: id-dsa OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) x9-57(10040) x9cm(4) 1 } " ^#(1 2 840 10040 4 1)
asn1TypeName ^#X509DSAPublicKey
</methods> <methods> Security.X509.X509DSAPublicKey class <category>marshaling</category>
adoptValue: value "Some keys are simple types that the ASN.1 framework can't map to class automatically, so we need to work around that here." ^self new publicKey: value; yourself
</methods> <methods> Security.X509.X509DSAPublicKey class <category>instance creation</category>
readFrom: stream "Decode an instance of the receiver from the <stream>. stream <ReadStream> readable binary stream " ^self adoptValue: (super readFrom: stream)
</methods> <methods> Security.X509.DSSSignatureValue <category>marshaling</category>
r: anInteger r := anInteger
s: anInteger s := anInteger
</methods> <methods> Security.X509.DSSSignatureValue <category>accessing</category>
asX509Signature ^self
getSignature ^DSASignature r: r s: s
r ^r
s ^s
</methods> <methods> Security.X509.DSSSignatureValue class <category>initialize-release</category>
initialize self initializeAsn1Types
initializeAsn1Types " Dss-Sig-Value ::= SEQUENCE { r INTEGER, s INTEGER } " ( ASN1Module SEQUENCE: #DSSSignature) addElement: #r type: #INTEGER; addElement: #s type: #INTEGER; mapping: self
</methods> <methods> Security.X509.DSSSignatureValue class <category>accessing</category>
oidCollection ^#()
</methods> <methods> Security.X509.NoExtensionSupport class <category>initialize-release</category>
initialize notifierString := #NoExtensionSupport << #security >> 'Extensions are not supported in this version of certificates!'
</methods> <methods> Security.X509.X509Notification <category>private - actions</category>
defaultAction "What to do when the exception is unhandled. By default, Notifications can be ignored." ^self defaultResumeValue
</methods> <methods> Security.X509.ExtensionShouldBeCritical <category>accessing</category>
extension ^extension
extension: anObject extension := anObject
</methods> <methods> Security.X509.AttributeValueAssertion <category>marshaling</category>
type: anOID type := anOID
value: aString value := aString
</methods> <methods> Security.X509.AttributeValueAssertion <category>accessing</category>
type "Answers the type component of the type/value pair" ^type
value "Answers the value component of the type/value pair" ^value
</methods> <methods> Security.X509.AttributeValueAssertion class <category>initialize-release</category>
initialize self initializeAsn1Types
initializeAsn1Types " AttributeType ::= OBJECT IDENTIFIER " ASN1Module OBJECT_IDENTIFIER: #AttributeType. " AttributeValue ::= ANY DEFINED BY AttributeType " ASN1Module ANY: #AttributeValue. " AttributeTypeAndValue ::= SEQUENCE { type AttributeType, value AttributeValue } " ( ASN1Module SEQUENCE: #AttributeTypeAndValue) addElement: #type type: #AttributeType; addElement: #value type: #AttributeValue; mapping: self
</methods> <methods> Security.X509.X509RSAPublicKey <category>marshaling</category>
marshalingValue ^self
modulus ^n
modulus: anInteger n := anInteger
publicExponent ^e
publicExponent: anInteger e := anInteger
value ^self
</methods> <methods> Security.X509.X509RSAPublicKey <category>printing</category>
printOpenSSLOn: aStream indent: level "This should print the key in the format used by OpenSSL" | keySize nArray | nArray := n asBigEndianByteArray. keySize :=nArray size * 8. aStream tab: level; nextPutAll: (#RSAPubKeyPrefix << #security >> 'RSA Public Key: (') asString; print: keySize; nextPutAll: (#BitsSuffix << #security >> ' bits)') asString; cr; tab: level + 1; nextPutAll: (#ModulusPrefix << #security >> 'Modulus (') asString; print: nArray size * 8; nextPutAll: (#BitSuffix << #security >> ' bit)') asString; nextPut: $:; cr. (#[0], nArray) printOpenSSLOn: aStream indent: level + 2 width: 15. aStream tab: level + 1; nextPutAll: (#ExponentPrefix << #security >> 'Exponent: ') asString; print: e ; nextPutAll: ' (0x'. e printOn: aStream base: 16. aStream nextPut: $); cr
</methods> <methods> Security.X509.X509RSAPublicKey <category>accessing</category>
e ^e
getKey ^RSAPublicKey e: e n: n
n ^n
</methods> <methods> Security.X509.X509RSAPublicKey <category>private</category>
assertEncryptionIn: aTBSCertificate "Mark this certificate as suitable for encryption of data." aTBSCertificate getEmptyKeyUsage dataEncipherment: true
assertKeyExchangeIn: aTBSCertificate "Mark this certificate as suitable for key exchange or key agreement depending on the key algorithm" aTBSCertificate getEmptyKeyUsage keyEncipherment: true
</methods> <methods> Security.X509.X509RSAPublicKey class <category>accessing</category>
algorithmOIDArray "RFC#3279 (section 2.3.1 RSA Keys): The OID rsaEncryption identifies RSA public keys. pkcs-1 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) 1 } rsaEncryption OBJECT IDENTIFIER ::= { pkcs-1 1} " ^#(1 2 840 113549 1 1 1)
asn1TypeName ^#X509RSAPublicKey
keyClass ^RSAPublicKey
</methods> <methods> Security.X509.X509RSAPublicKey class <category>initialize-release</category>
initialize self initializeAsn1Types
initializeAsn1Types " RSAPublicKey ::= SEQUENCE { modulus INTEGER, -- n publicExponent INTEGER -- e } " ( ASN1Module SEQUENCE: self asn1TypeName) addElement: #modulus type: #INTEGER; addElement: #publicExponent type: #INTEGER; mapping: self
</methods> <methods> Security.X509.BasicConstraints <category>accessing</category>
ca " ^<Boolean> is the subject a certificate issuing authority ? " ^ca
ca: aBoolean " aBoolean <Boolean> is the subject a certificate issuing authority ? " ca := aBoolean
depth " ^<Integer> maximum depth of valid certification paths that include this certificate " ^depth
depth: anInteger " anInteger <Integer> maximum depth of valid certification paths that include this certificate " depth := anInteger
</methods> <methods> Security.X509.BasicConstraints <category>testing</category>
isBasicConstraints ^true
isHandled ^true
shouldBeCritical ^true
</methods> <methods> Security.X509.BasicConstraints <category>marshaling</category>
cA ^self ca
cA: aBoolean self ca: aBoolean
pathLenConstraint ^self depth
pathLenConstraint: anObject self depth: anObject
</methods> <methods> Security.X509.BasicConstraints <category>printing</category>
printOpenSSLOn: aStream indent: level "This should print the extension in the format used by OpenSSL" aStream cr; tab: level; nextPutAll: (#BasicConstraintsPrefix << #security >> 'X509v3 Basic Constraints:') asString. critical ifTrue: [aStream nextPutAll: (#CriticalSuffix << #security >> ' critical') asString ]. aStream cr; tab: level + 1; nextPutAll: (#CAPrefix << #security >> 'CA:') asString. aStream nextPutAll: (ca ifTrue: [(#TRUE << #security >> 'TRUE') asString] ifFalse: [(#FALSE << #security >> 'FALSE') asString]); cr. depth ifNotNil: [ :len | aStream tab: level + 1; nextPutAll: (#pathLenPrefix << #security >> 'pathLen: ') asString; print: len; cr ].
</methods> <methods> Security.X509.BasicConstraints class <category>private</category>
oidString ^'2.5.29.19'
</methods> <methods> Security.X509.BasicConstraints class <category>accessing</category>
asn1TypeName "Answer the ASN.1 type name for the extension value." ^#BasicConstraints
</methods> <methods> Security.X509.BasicConstraints class <category>initialize-release</category>
initialize self initializeAsn1Types
initializeAsn1Types " BasicConstraints ::= SEQUENCE { cA BOOLEAN DEFAULT FALSE, pathLenConstraint INTEGER (0..MAX) OPTIONAL } " (ASN1Module SEQUENCE: #BasicConstraints) addElement: #cA type: #BOOLEAN default: false; addOptionalElement: #pathLenConstraint type: #INTEGER; mapping: self
</methods> <methods> Security.X509.X509RSAPrivateKey <category>marshaling</category>
coefficient ^coefficient
coefficient: anInteger coefficient := anInteger
exponent1 ^exponent1
exponent1: anInteger exponent1 := anInteger
exponent2 ^exponent2
exponent2: anInteger exponent2 := anInteger
modulus ^n
modulus: anInteger n := anInteger
prime1 ^p
prime1: anInteger p := anInteger
prime2 ^q
prime2: anInteger q := anInteger
privateExponent ^d
privateExponent: anInteger d := anInteger
publicExponent ^e
publicExponent: anInteger e := anInteger
version ^version ifNil: [ 0 ]
version: anInteger version := anInteger
</methods> <methods> Security.X509.X509RSAPrivateKey <category>accessing</category>
d ^d
e ^e
getKey ^RSAPrivateKey new d: d; n: n; e: e; p: p; q: q; dp: exponent1; dq: exponent2; qInv: coefficient; yourself
n ^n
p ^p
q ^q
</methods> <methods> Security.X509.X509RSAPrivateKey <category>printing</category>
printOpenSSLOn: aStream indent: level "This should print the key in the format used by OpenSSL" | keySize nArray | nArray := n asBigEndianByteArray. keySize :=nArray size * 8. aStream tab: level; nextPutAll: (#RSAPrivateKeyPrefix << #security >> 'RSA Private Key: (') asString; print: keySize; nextPutAll: (#BitsSuffix << #security >> ' bits)') asString; cr. aStream tab: level; nextPutAll: (#modulus << #security >> 'modulus:') asString; cr. nArray printOpenSSLOn: aStream indent: level + 1 width: 15. aStream tab: level; nextPutAll: (#publicExponent << #security >> 'publicExponent: ') asString; print: e ; nextPutAll: ' (0x'. e printOn: aStream base: 16. aStream nextPut: $); cr. aStream tab: level; nextPutAll: (#privateExponent << #security >> 'privateExponent:') asString; cr. d asBigEndianByteArray printOpenSSLOn: aStream indent: level + 1 width: 15. aStream tab: level; nextPutAll: (#prime1 << #security >> 'prime1:') asString; cr. #[0], p asBigEndianByteArray printOpenSSLOn: aStream indent: level + 1 width: 15. aStream tab: level; nextPutAll: (#prime2 << #security >> 'prime2:') asString; cr. #[0], q asBigEndianByteArray printOpenSSLOn: aStream indent: level + 1 width: 15. aStream tab: level; nextPutAll: (#exponent1 << #security >> 'exponent1:') asString; cr. exponent1 asBigEndianByteArray printOpenSSLOn: aStream indent: level + 1 width: 15. aStream tab: level; nextPutAll: (#exponent2 << #security >> 'exponent2:') asString; cr. exponent2 asBigEndianByteArray printOpenSSLOn: aStream indent: level + 1 width: 15. aStream tab: level; nextPutAll: (#coefficient << #security >> 'coefficient:') asString; cr. coefficient abs asBigEndianByteArray printOpenSSLOn: aStream indent: level + 1 width: 15.
</methods> <methods> Security.X509.X509RSAPrivateKey class <category>initialize-release</category>
initialize self initializeAsn1Types
initializeAsn1Types " See the man page for the rsa command in the openssl suite, option -inform RSAPrivateKey ::= SEQUENCE { version Version, modulus INTEGER, -- n publicExponent INTEGER, -- e privateExponent INTEGER, -- d prime1 INTEGER, -- p prime2 INTEGER, -- q exponent1 INTEGER, -- d mod (p-1) exponent2 INTEGER, -- d mod (q-1) coefficient INTEGER -- (inverse of q) mod p } Version ::= INTEGER " ( ASN1Module SEQUENCE: self asn1TypeName ) addElement: #version type: #INTEGER; addElement: #modulus type: #INTEGER; addElement: #publicExponent type: #INTEGER; addElement: #privateExponent type: #INTEGER; addElement: #prime1 type: #INTEGER; addElement: #prime2 type: #INTEGER; addElement: #exponent1 type: #INTEGER; addElement: #exponent2 type: #INTEGER; addElement: #coefficient type: #INTEGER; mapping: self
</methods> <methods> Security.X509.X509RSAPrivateKey class <category>accessing</category>
asn1TypeName ^#X509RSAPrivateKey
keyClass ^RSAPrivateKey
</methods> <methods> Security.X509.X509RSAPrivateKey class <category>utilities</category>
canReadPEM: mark ^'*rsa*private*key*' match: mark
</methods> <methods> Security.X509.AlgorithmIdentifier <category>accessing</category>
getOID "Answers the OID for this algorithm" ^oid
getOIDDescription "Answers the OID description for this algorithm" ^oidDescription
getOIDSymbol "Answers object identifier asSymbol" ^oid getOIDSymbol
getOLDOIDSymbol "Answers object identifier asSymbol" | oidString ix | oidString := oid copy. oidString := 'x' , self getOID. ix := 1. [ix < oidString size] whileTrue: [(oidString at: ix) = $. ifTrue: [oidString at: ix put: $x]. ix := ix + 1]. ^oidString asSymbol
parameters ^parameters
parameters: anOrderedCollection parameters := anOrderedCollection
</methods> <methods> Security.X509.AlgorithmIdentifier <category>accessing-algorithms</category>
dsa_with_sha1 ^self id_dsa_with_sha1
getAlgorithm | selector | selector := oid leafSymbol. (selector includes: $-) ifTrue: [ selector := (selector asString replaceAll: $- with: $_) asSymbol ]. ^(self respondsTo: selector) ifTrue: [ self perform: selector ] ifFalse: [ nil ]
id_dsa_with_sha1 ^DSA new
md5WithRSAEncryption ^RSA new useMD5; yourself
sha1WithRSAEncryption ^self sha_1WithRSAEncryption
sha1_with_rsa_signature ^self sha_1WithRSAEncryption
sha_1WithRSAEncryption ^RSA new useSHA; yourself
</methods> <methods> Security.X509.AlgorithmIdentifier <category>services</category>
verify: aSubjectCertificate isSignedBy: anIssuerCertificate | algorithm | (algorithm := self getAlgorithm) ifNil: [ Unsupported new messageText: (#UnsupportedSigAlg << #security >> 'Signature algorithm is not supported!'); parameter: aSubjectCertificate; isResumable: true; raiseSignal. ^false ]. anIssuerCertificate subjectPublicKeyAlgorithmOID = algorithm x509AlgorithmOID ifFalse: [ InvalidSignature new messageText: (#IssuerSigAlgMismatch << #security >> 'Public key of the issuer does not match the signature algorithm!'); parameter: (Array with: aSubjectCertificate with: anIssuerCertificate); isResumable: true; raiseSignal. ^false ]. ^algorithm publicKey: anIssuerCertificate publicKey; verify: aSubjectCertificate getSignature of: aSubjectCertificate tbsDerCertificate
</methods> <methods> Security.X509.AlgorithmIdentifier <category>marshaling</category>
algorithm ^oid
algorithm: anOID oid := anOID. oidDescription := oid getShortOIDDescription.
</methods> <methods> Security.X509.AlgorithmIdentifier <category>testing</category>
isDSA ^oid = self class id_dsa_with_sha1OID
</methods> <methods> Security.X509.AlgorithmIdentifier class <category>accessing</category>
asn1TypeName ^#AlgorithmIdentifier
</methods> <methods> Security.X509.AlgorithmIdentifier class <category>instance creation</category>
id_dsa_with_sha1 "RFC 3279 (section 2.2.2 DSA Signature Algorithm): The Digital Signature Algorithm (DSA) is defined in the Digital Signature Standard (DSS). DSA was developed by the U.S. Government, and DSA is used in conjunction with the SHA-1 one-way hash function. DSA is fully described in [FIPS 186]. The ASN.1 OID used to identify this signature algorithm is: id-dsa-with-sha1 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) x9-57 (10040) x9cm(4) 3 } When the id-dsa-with-sha1 algorithm identifier appears as the algorithm field in an AlgorithmIdentifier, the encoding SHALL omit the parameters field. That is, the AlgorithmIdentifier SHALL be a SEQUENCE of one component: the OBJECT IDENTIFIER id-dsa-with-sha1. The DSA parameters in the subjectPublicKeyInfo field of the certificate of the issuer SHALL apply to the verification of the signature. self id_dsa_with_sha1 " ^self new algorithm: self id_dsa_with_sha1OID; yourself
md5WithRSAEncryption "RFC 3279 (section 2.2.1 RSA Signature Algorithm): The signature algorithm with MD5 and the RSA encryption algorithm is defined in PKCS #1 [RFC 2313]. As defined in PKCS #1 [RFC 2313], the ASN.1 OID used to identify this signature algorithm is: md5WithRSAEncryption OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-1(1) 4 } When any of these three OIDs appears within the ASN.1 type AlgorithmIdentifier, the parameters component of that type SHALL be the ASN.1 type NULL. The RSA signature generation process and the encoding of the result is described in detail in PKCS #1 [RFC 2313]. self md5WithRSAEncryption " ^self new algorithm: (ObjectIdentifier value: #(1 2 840 113549 1 1 4)); "The following is necessary because parameters are defined as optional ANY and using simply nil represents absence of the optional element. Using a type wrapper signifies presence of NULL value." parameters: (TypeWrapper type: ANY new value: nil); yourself
sha_1WithRSAEncryption "RFC 3279 (section 2.2.1 RSA Signature Algorithm): The signature algorithm with MD5 and the RSA encryption algorithm is defined in PKCS #1 [RFC 2313]. As defined in PKCS #1 [RFC 2313], the ASN.1 OID used to identify this signature algorithm is: sha-1WithRSAEncryption OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-1(1) 5 } When any of these three OIDs appears within the ASN.1 type AlgorithmIdentifier, the parameters component of that type SHALL be the ASN.1 type NULL. The RSA signature generation process and the encoding of the result is described in detail in PKCS #1 [RFC 2313]. self sha_1WithRSAEncryption " ^self new algorithm: (ObjectIdentifier value: #(1 2 840 113549 1 1 5)); "The following is necessary because parameters are defined as optional ANY and using simply nil represents absence of the optional element. Using a type wrapper signifies presence of NULL value." parameters: (TypeWrapper type: ANY new value: nil); yourself
</methods> <methods> Security.X509.AlgorithmIdentifier class <category>initialize-release</category>
initialize self initializeAsn1Types; initializeSMINodes
initializeAsn1Types " AlgorithmIdentifier ::= SEQUENCE { algorithm OBJECT IDENTIFIER, parameters ANY DEFINED BY algorithm OPTIONAL } " ( ASN1Module SEQUENCE: self asn1TypeName ) addElement: #algorithm type: #OBJECT_IDENTIFIER; addOptionalElement: #parameters type: #ANY; mapping: self
initializeSMINodes "Add Algorithm OIDs from RFC#3279: Algorithms and Identifiers for the Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile." SMINode root " 2.2.1 RSA Signature Algorithm The RSA signature algorithm, as specified in PKCS #1 [RFC 2313] includes a data encoding step. In this step, the message digest and the OID for the one-way hash function used to compute the digest are combined. When performing the data encoding step, the md2, md5, and id-sha1 OIDs MUST be used to specify the MD2, MD5, and SHA-1 one-way hash functions, respectively: md2 OBJECT IDENTIFIER ::= { iso(1) member-body(2) US(840) rsadsi(113549) digestAlgorithm(2) 2 } md5 OBJECT IDENTIFIER ::= { iso(1) member-body(2) US(840) rsadsi(113549) digestAlgorithm(2) 5 } id-sha1 OBJECT IDENTIFIER ::= { iso(1) identified-organization(3) oiw(14) secsig(3) algorithms(2) 26 } " atPath: #( 1 2 840 113549 ) setSymbol: 'rsadsi'; atPath: #( 1 2 840 113549 2) setSymbol: 'digestAlgorithm'; atPath: #( 1 2 840 113549 2 2) setSymbol: 'md2'; atPath: #( 1 2 840 113549 2 5) setSymbol: 'md5'; atPath: #( 1 3 14 3 ) setSymbol: 'secsig'; atPath: #( 1 3 14 3 2 ) setSymbol: 'algorithms'; atPath: #( 1 3 14 3 2 12 ) setSymbol: 'dsa'; atPath: #( 1 3 14 3 2 26 ) setSymbol: 'sha1'; atPath: #( 1 3 14 3 2 27 ) setSymbol: 'dsaWithSHA1'; " The signature algorithm with MD2 and the RSA encryption algorithm is defined in PKCS #1 [RFC 2313]. As defined in PKCS #1 [RFC 2313], the ASN.1 OID used to identify this signature algorithm is: md2WithRSAEncryption OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-1(1) 2 } " atPath: #( 1 2 840 113549 1 ) setSymbol: 'pkcs'; atPath: #( 1 2 840 113549 1 1 ) setSymbol: 'pkcs-1'; atPath: #( 1 2 840 113549 1 1 2 ) setSymbol: 'md2WithRSAEncryption'; " The signature algorithm with MD5 and the RSA encryption algorithm is defined in PKCS #1 [RFC 2313]. As defined in PKCS #1 [RFC 2313], the ASN.1 OID used to identify this signature algorithm is: md5WithRSAEncryption OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-1(1) 4 } " atPath: #( 1 2 840 113549 1 1 4 ) setSymbol: 'md5WithRSAEncryption'; " The ASN.1 object identifier used to identify this signature algorithm is: sha-1WithRSAEncryption OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-1(1) 5 } " atPath: #( 1 2 840 113549 1 1 5 ) setSymbol: 'sha-1WithRSAEncryption'; " From PKCS #1 V2.1: RSA CRYPTOGRAPHY STANDARD (June 14, 2002), Appendix C. ASN.1 module md2WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 2 } md5WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 4 } sha1WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 5 } sha256WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 11 } sha384WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 12 } sha512WithRSAEncryption OBJECT IDENTIFIER ::= { pkcs-1 13 } " atPath: #( 1 2 840 113549 1 1 11 ) setSymbol: 'sha256WithRSAEncryption'; atPath: #( 1 2 840 113549 1 1 12 ) setSymbol: 'sha348WithRSAEncryption'; atPath: #( 1 2 840 113549 1 1 13 ) setSymbol: 'sha512WithRSAEncryption'; " 2.2.2 DSA Signature Algorithm The Digital Signature Algorithm (DSA) is defined in the Digital Signature Standard (DSS). DSA was developed by the U.S. Government, and DSA is used in conjunction with the SHA-1 one-way hash function. DSA is fully described in [FIPS 186]. The ASN.1 OID used to identify this signature algorithm is: id-dsa-with-sha1 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) x9-57 (10040) x9cm(4) 3 } " atPath: #( 1 2 840 10040 ) setSymbol: 'x9-57'; atPath: #( 1 2 840 10040 4 ) setSymbol: 'x9algorithm'; atPath: #( 1 2 840 10040 4 3 ) setSymbol: 'dsa-with-sha1'; " 2.2.3 ECDSA Signature Algorithm The Elliptic Curve Digital Signature Algorithm (ECDSA) is defined in [X9.62]. The ASN.1 object identifiers used to identify ECDSA are defined in the following arc: ansi-X9-62 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) 10045 } id-ecSigType OBJECT IDENTIFIER ::= { ansi-X9-62 signatures(4) } ECDSA is used in conjunction with the SHA-1 one-way hash function. The ASN.1 object identifier used to identify ECDSA with SHA-1 is: ecdsa-with-SHA1 OBJECT IDENTIFIER ::= { id-ecSigType 1 } " atPath: #( 1 2 840 10045 ) setSymbol: 'x9-62'; atPath: #( 1 2 840 10045 4 ) setSymbol: 'ecSigType'; atPath: #( 1 2 840 10045 4 1) setSymbol: 'ecdsa-with-SHA1'; " 2.3 Subject Public Key Algorithms " " 2.3.1 RSA Keys The OID rsaEncryption identifies RSA public keys. pkcs-1 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) 1 } rsaEncryption OBJECT IDENTIFIER ::= { pkcs-1 1} " atPath: #( 1 2 840 113549 1 1 1) setSymbol: 'rsaEncryption'; " 2.3.2 DSA Signature Keys The Digital Signature Algorithm (DSA) is defined in the Digital Signature Standard (DSS) [FIPS 186]. The DSA OID supported by this profile is: id-dsa OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) x9-57(10040) x9cm(4) 1 } " atPath: #( 1 2 840 10040 4 1 ) setSymbol: 'dsa'; " 2.3.3 Diffie-Hellman Key Exchange Keys The Diffie-Hellman OID supported by this profile is defined in [X9.42]. dhpublicnumber OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) ansi-x942(10046) number-type(2) 1 } " atPath: #( 1 2 840 10046 ) setSymbol: 'x9-42'; atPath: #( 1 2 840 10046 2 ) setSymbol: 'number-types'; atPath: #( 1 2 840 10046 2 1 ) setSymbol: 'dhpublicnumber'; " 2.3.4 KEA Public Keys When the SubjectPublicKeyInfo field contains a KEA key, the algorithm identifier and parameters SHALL be as defined in [SDN.701r]: id-keyExchangeAlgorithm OBJECT IDENTIFIER ::= { 2 16 840 1 101 2 1 1 22 } " atPath: #( 1 2 840 1 101 2 1 1 22 ) setSymbol: 'keyExchangeAlgorithm'; " 2.3.5 ECDSA and ECDH Keys The ECDSA and ECDH specifications use the same OIDs and parameter encodings. The ASN.1 object identifiers used to identify these public keys are defined in the following arc: ansi-X9-62 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) 10045 } When certificates contain an ECDSA or ECDH public key, the id-ecPublicKey algorithm identifier MUST be used. The id-ecPublicKey algorithm identifier is defined as follows: id-public-key-type OBJECT IDENTIFIER ::= { ansi-X9.62 2 } id-ecPublicKey OBJECT IDENTIFIER ::= { id-publicKeyType 1 } " atPath: #( 1 2 840 10045 2) setSymbol: 'public-key-type'; atPath: #( 1 2 840 10045 2 1) setSymbol: 'ecPublicKey'; yourself
</methods> <methods> Security.X509.AlgorithmIdentifier class <category>constants</category>
id_dsa_with_sha1OID "RFC 3279 (section 2.2.2 DSA Signature Algorithm): The Digital Signature Algorithm (DSA) is defined in the Digital Signature Standard (DSS). DSA was developed by the U.S. Government, and DSA is used in conjunction with the SHA-1 one-way hash function. DSA is fully described in [FIPS 186]. The ASN.1 OID used to identify this signature algorithm is: id-dsa-with-sha1 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) x9-57 (10040) x9cm(4) 3 } " ^ObjectIdentifier value: #(1 2 840 10040 4 3)
</methods> <methods> Security.X509.SubjectPublicKeyInfo <category>accessing</category>
algorithm ^algorithm
getPublicKey ^publicKey getKey
publicKey ^publicKey
publicKey: aPublicKey publicKey := aPublicKey asX509PublicKey. algorithm := AlgorithmIdentifier new algorithm: publicKey algorithmOID; yourself. publicKey algorithmParameters ifNotNil: [ :params | algorithm parameters: params ]
</methods> <methods> Security.X509.SubjectPublicKeyInfo <category>marshaling</category>
algorithm: anAlgorithmIdentifier algorithm := anAlgorithmIdentifier
subjectPublicKey ^subjectPublicKey ifNil: [ self publicKey ifNotNil: [ :key || stream | stream := DERStream on: (ByteArray new: 300). stream marshalObject: key marshalingValue withType: key asn1Type. subjectPublicKey := BitString unused: 0 bytes: stream contents ] ]
subjectPublicKey: aBitString | keyClass marshaler | subjectPublicKey := aBitString. keyClass := X509PublicKey keyClassFor: algorithm. keyClass ifNil: [ publicKey := subjectPublicKey. ^self ]. marshaler := DERStream with: subjectPublicKey value. marshaler reset. publicKey := marshaler unmarshalObjectType: keyClass asn1Type. publicKey := keyClass adoptValue: publicKey. algorithm parameters ifNotNil:[ :params | publicKey algorithmParameters: params ]
</methods> <methods> Security.X509.SubjectPublicKeyInfo <category>printing</category>
printOpenSSLOn: aStream indent: level "This should print the key info in the format used by OpenSSL" aStream tab: level; nextPutAll: (#PubKeyAlgPrefix << #security >> 'Public Key Algorithm: ') asString; nextPutAll: algorithm getOIDDescription; cr. publicKey printOpenSSLOn: aStream indent: level
</methods> <methods> Security.X509.SubjectPublicKeyInfo <category>private</category>
getX509DSAPublicKey | bytes marshaler key | bytes := subjectPublicKey value. marshaler := DERStream with: bytes. marshaler reset. key := marshaler unmarshalObjectType: ( ASN1Module find: #X509DSAPublicKey ). "The ASN.1 marshaler can't map integers to Smalltalk classes yet, so we need to help here as well" key := X509DSAPublicKey new publicKey: key; yourself. algorithm parameters ifNotNil:[ :params | key dssParameters: ( DSSParameters p: (params at: 1) q: (params at: 2) g: (params at: 3) ) ]. ^key
getX509RSAPublicKey | bytes marshaler | bytes := subjectPublicKey value. marshaler := DERStream with: bytes. marshaler reset. ^marshaler unmarshalObjectType: ( ASN1Module find: #X509RSAPublicKey )
</methods> <methods> Security.X509.SubjectPublicKeyInfo class <category>initialize-release</category>
initialize self initializeAsn1Types
initializeAsn1Types " SubjectPublicKeyInfo ::= SEQUENCE { algorithm AlgorithmIdentifier, subjectPublicKey BIT STRING } " ( ASN1Module SEQUENCE: self asn1TypeName) addElement: #algorithm type: #AlgorithmIdentifier; addElement: #subjectPublicKey type: #BIT_STRING; mapping: self
</methods> <methods> Security.X509.SubjectPublicKeyInfo class <category>accessing</category>
asn1TypeName ^#SubjectPublicKeyInfo
</methods> <methods> Security.X509.UnhandledCriticalExtension <category>accessing</category>
extension ^extension
extension: anObject extension := anObject
</methods> <methods> Security.X509.X509DSAPrivateKey <category>marshaling</category>
g: anObject g := anObject
p: anObject p := anObject
q: anObject q := anObject
version ^version ifNil: [0]
version: anInteger version := anInteger
x: anObject x := anObject
y: anObject y := anObject
</methods> <methods> Security.X509.X509DSAPrivateKey <category>accessing</category>
g ^g
getKey ^DSAPrivateKey p: p q: q g: g x: x
p ^p
q ^q
x ^x
y ^y
</methods> <methods> Security.X509.X509DSAPrivateKey <category>printing</category>
printOpenSSLOn: aStream indent: level "This should print the key in the format used by OpenSSL" | pArray | pArray := p asBigEndianByteArray. aStream tab: level; nextPutAll: (#DSAPubKeyPrefix << #security >> 'DSA Public Key: (') asString; print: pArray size * 8; nextPutAll: (#BitsSuffix << #security >> ' bits)') asString; cr. aStream tab: level; nextPutAll: (#privPrefix << #security >> 'priv:') asString; cr. x asBigEndianByteArray printOpenSSLOn: aStream indent: level + 1 width: 15. aStream tab: level; nextPutAll: (#pubPrefix << #security >> 'pub:') asString; cr. y asBigEndianByteArray printOpenSSLOn: aStream indent: level + 1 width: 15. aStream tab: level; nextPutAll: (#PPrefix << #security >> 'P:') asString; cr. #[0], pArray printOpenSSLOn: aStream indent: level + 1 width: 15. aStream tab: level; nextPutAll: (#QPrefix << #security >> 'Q:') asString; cr. #[0], q asBigEndianByteArray printOpenSSLOn: aStream indent: level + 1 width: 15. aStream tab: level; nextPutAll: (#GPrefix << #security >> 'G:') asString; cr. g asBigEndianByteArray printOpenSSLOn: aStream indent: level + 1 width: 15.
</methods> <methods> Security.X509.X509DSAPrivateKey class <category>initialize-release</category>
initialize self initializeAsn1Types
initializeAsn1Types " See the man page for the dsa command in the openssl suite, option -inform DSAPrivateKey ::= SEQUENCE { version INTEGER, -- curently zero p INTEGER, q INTEGER, g INTEGER , y INTEGER, x INTEGER } " ( ASN1Module SEQUENCE: self asn1TypeName ) addElement: #version type: #INTEGER; addElement: #p type: #INTEGER; addElement: #q type: #INTEGER; addElement: #g type: #INTEGER; addElement: #y type: #INTEGER; addElement: #x type: #INTEGER; mapping: self
</methods> <methods> Security.X509.X509DSAPrivateKey class <category>utilities</category>
canReadPEM: mark ^'*dsa*private*key*' match: mark
</methods> <methods> Security.X509.X509DSAPrivateKey class <category>accessing</category>
asn1TypeName ^#X509DSAPrivateKey
</methods> <methods> Security.X509.Certificate <category>marshaling</category>
encoding: anEncoding encoding := anEncoding
signature: aSignature signature := aSignature. signatureValue := aSignature. signatureAlgorithm isDSA ifTrue: [ | marshaler | marshaler := DERStream on: (ByteArray new: 500). marshaler marshalObject: signatureValue withType: ( ASN1Module find: #DSSSignature ). signatureValue := marshaler contents. signature := aSignature asX509Signature ]. signatureValue := BitString unused: 0 bytes: signatureValue.
signatureAlgorithm: anAlgorithmIdentifier signatureAlgorithm := anAlgorithmIdentifier
signatureValue ^signatureValue
signatureValue: aBitString signatureValue := aBitString. signature := aBitString value. signatureAlgorithm isDSA ifTrue: [ | marshaler | marshaler := DERStream with: signature. marshaler reset. signature := marshaler unmarshalObjectType: ( ASN1Module find: #DSSSignature ) ]
tbsCertificate ^tbsCertificate ifNil: [ tbsCertificate := TBSCertificate new ]
tbsCertificate: aTBCCertificate tbsCertificate := aTBCCertificate
_encoding ^encoding
_encoding: anEncoding type: aType encoding := anEncoding
</methods> <methods> Security.X509.Certificate <category>testing</category>
isForCA "Assert/Deny that usage indicates CA purposes, i.e. certificate and CRL signing. " ^self isCrlSign or: [ self isKeyCertSign ]
isForEncryption "Assert/Deny that usage indicates data encryption. " ^self isDataEncipherment
isForKeyEstablishment "Assert/Deny that usage indicates key establishment purposes. " ^self isKeyEncipherment or: [ self isKeyAgreement ]
isForSigning "Assert/Deny that usage indicates data signing. " ^self isDigitalSignature
isSameAs: certificate "Test if the receiver is the same as certificate. ^<Boolean> " ^certificate signatureBytes = self signatureBytes
isVersionOne ^self version = 1
isVersionThree ^self version = 3
</methods> <methods> Security.X509.Certificate <category>accessing - signature</category>
getSignature ^signature class = ByteArray ifTrue: [signature] ifFalse: [signature getSignature]
signature ^signature
signatureAlgorithm ^signatureAlgorithm
signatureAlgorithmOID "Answers the OID of the algorithm used to sign this certificate" ^signatureAlgorithm getOID
signatureAlgorithmOIDDescription "description of the OID of the algorithm used to sign this certificate" ^signatureAlgorithm getOIDDescription
signatureBytes ^signatureValue bytes
signUsing: signer "Sign the receiver using the signer. signer <AsymmetricCipher | PrivateKey> algorithm or signing key to use to sign the receiver " | algorithm bytes identifier | algorithm := signer x509AsAlgorithm. identifier := algorithm x509AlgorithmIdentifier. self tbsCertificate signatureAlgorithm: identifier. bytes := self tbsCertificate derCertificate. self signatureAlgorithm: identifier. self signature: (algorithm sign: bytes).
tbsSignatureAlgorithm ^self tbsCertificate signatureAlgorithm
tbsSignatureAlgorithmOID "Answers the OID of the algorithm used to sign this certificate" ^self tbsCertificate signatureAlgorithmOID
tbsSignatureAlgorithmOIDDescription "description of the OID of the algorithm used to sign this certificate" ^self tbsCertificate signatureAlgorithmOIDDescription
</methods> <methods> Security.X509.Certificate <category>accessing - subject</category>
subject ^self tbsCertificate subject
subject: anX509Name self tbsCertificate subject: anX509Name
subjectDN "Answers the distinguished name of the subject" ^self tbsCertificate subjectDN
subjectDNInBytes "Answers the distinguished name of the subject" ^self tbsCertificate subjectDNInBytes
</methods> <methods> Security.X509.Certificate <category>accessing - extensions - key usage</category>
hasKeyUsage ^self tbsCertificate hasKeyUsage
isCrlSign ^self tbsCertificate isCrlSign
isDataEncipherment ^self tbsCertificate isDataEncipherment
isDecipherOnly ^self tbsCertificate isDecipherOnly
isDigitalSignature ^self tbsCertificate isDigitalSignature
isEncipherOnly ^self tbsCertificate isEncipherOnly
isKeyAgreement ^self tbsCertificate isKeyAgreement
isKeyCertSign ^self tbsCertificate isKeyCertSign
isKeyEncipherment ^self tbsCertificate isKeyEncipherment
isNonRepudiation ^self tbsCertificate isNonRepudiation
keyUsage ^self tbsCertificate keyUsage
</methods> <methods> Security.X509.Certificate <category>accessing - internals</category>
derCertificate "Answers the DER encoded certificate" ^(encoding ifNil: [ | marshaler | marshaler := DERStream on: (ByteArray new: 100). marshaler marshalObject: self withType: self asn1Type. encoding := Encoding with: marshaler contents ] ) fullEncoding
encoding ^encoding
tbsDerCertificate "Answers the DER encoded certificate" ^self tbsCertificate derCertificate
tbsEncoding ^self tbsCertificate encoding
</methods> <methods> Security.X509.Certificate <category>accessing - validity</category>
isExpired ^tbsCertificate isExpired
isNotValidYet ^tbsCertificate isNotValidYet
isValid ^tbsCertificate isValid
isValidOn: time ^tbsCertificate isValidOn: time
notAfter "a string containing notAfter as a UTCTIME" ^self tbsCertificate notAfter
notAfter: aTimestamp self tbsCertificate notAfter: aTimestamp
notAfterDate "an instance of Date containing the date of notAfter" ^self tbsCertificate notAfterDate
notAfterTime " instance of Time containing the time of notAfter" ^self tbsCertificate notAfterTime
notBefore "string containing notBefore as a UTCTIME" ^self tbsCertificate notAfter
notBefore: aTimestamp self tbsCertificate notBefore: aTimestamp
notBeforeDate "instance of Date containing the date of notBefore" ^self tbsCertificate notBeforeDate
notBeforeTime " instance of Time containing the time of notBefore" ^self tbsCertificate notBeforeTime
</methods> <methods> Security.X509.Certificate <category>accessing - key</category>
publicKey ^self tbsCertificate publicKey
publicKey: aPublicKey self tbsCertificate publicKey: aPublicKey
subjectPublicKeyAlgorithmOID "OID of the algorithm used to generate the subject's public key" ^self tbsCertificate subjectPublicKeyInfo algorithm getOID
subjectPublicKeyAlgorithmOIDDescription "description of the OID of the algorithm used to generate the subject's public key" ^self tbsCertificate subjectPublicKeyInfo algorithm getOIDDescription
subjectPublicKeyInfo "Answers the subject's public key" ^self tbsCertificate subjectPublicKeyInfo
</methods> <methods> Security.X509.Certificate <category>accessing - issuer</category>
issuer ^self tbsCertificate issuer
issuer: anX509Name self tbsCertificate issuer: anX509Name
issuerDN "Answers the distinguished name of the issuer" ^self tbsCertificate issuerDN
issuerDNInBytes "Answers the distinguished name of the issuer in Bytes" ^self tbsCertificate issuerDNInBytes
</methods> <methods> Security.X509.Certificate <category>accessing - extensions - basic constraints</category>
basicConstraints ^self tbsCertificate basicConstraints
getBasicConstraints ^self tbsCertificate getBasicConstraints
hasBasicConstraints ^self tbsCertificate hasBasicConstraints
isCACertificate ^self tbsCertificate isCACertificate
</methods> <methods> Security.X509.Certificate <category>accessing</category>
serialNumber "Answers the serial number of certificate" ^self tbsCertificate serialNumber
serialNumber: anInteger self tbsCertificate serialNumber: anInteger
version "Answers the version number of the certificate" ^self tbsCertificate versionName
</methods> <methods> Security.X509.Certificate <category>deprecated</category>
getPublicKey ^self publicKey
getRSAPublicKey ^self tbsCertificate subjectPublicKeyInfo publicKey getKey
isBeforeValidityDate ^self isNotValidYet
verifySignature "This seems like a gratuitous API padding. See below." self verifySignedBy: self
verifyValidityPeriod "Responsibility moved to X509Registry. " self isNotValidYet ifTrue: [ NotValidYet new messageText: (#CertificateNotValidYet << #security >> 'Certificate not valid yet!'); parameter: self; isResumable: true; raiseSignal ]. self isExpired ifTrue: [ Expired new messageText: (#CertificateExpired << #security >> 'Certificate expired!'); parameter: self; isResumable: true; raiseSignal].
</methods> <methods> Security.X509.Certificate <category>utilities</category>
flushEncoding self encoding: nil. self tbsCertificate flushEncoding
</methods> <methods> Security.X509.Certificate <category>accessing - extensions</category>
addExtension: anExtension ^self tbsCertificate addExtension: anExtension
criticalExtensions ^self tbsCertificate criticalExtensions
extension: detectionBlock ifAbsent: notFoundBlock ^self tbsCertificate extension: detectionBlock ifAbsent: notFoundBlock
extensions ^self tbsCertificate extensions
getExtension: extensionClass ^self tbsCertificate getExtension: extensionClass
hasExtensions ^self tbsCertificate hasExtensions
</methods> <methods> Security.X509.Certificate <category>accessing - key usage</category>
forCertificateSigning "Mark the certificate as suitable for signing other certificates." self tbsCertificate forCertificateSigning
forCertificateSigning: depth "Mark the certificate as suitable for signing other certificates. depth <Integer> what is the maximum length of valid certificate chain with this certificate as root" self tbsCertificate forCertificateSigning: depth
forCRLSigning "Mark the certificate as suitable for signing CRLs." self tbsCertificate forCRLSigning
forEncryption "Mark this certificate as suitable for encryption of data." self tbsCertificate forEncryption
forKeyExchange "Mark this certificate as suitable for key exchange or key agreement depending on the key algorithm" self tbsCertificate forKeyExchange
forSigning "Mark this certificate as suitable for signing anything except certificates and CRLs" self tbsCertificate forSigning
</methods> <methods> Security.X509.Certificate <category>printing</category>
getFormattedCertificate "Answers a String containing the formatted self" | s idn i pk | s := WriteStream on: String new. s nextPutAll: (#CertificateVersionPrefix << #security >> 'X509 Certificate Version: ') asString; nextPutAll: self version printString; nextPutAll: ' ', (#SerialNumberPrefix << #security >> 'Serial Number: ') asString; nextPutAll: self serialNumber printString. idn := self issuerDN. s cr; cr; nextPutAll: (#IssuerPrefix << #security >> 'Issuer: ') asString. idn := self issuerDN. i := 1. idn size timesRepeat: [s nextPutAll: (idn at: i) type getOIDDescription; nextPutAll: '='; nextPutAll: (idn at: i) value . i = idn size ifFalse: [s nextPutAll: ', ']. i := i + 1]. s cr; cr. idn := self issuerDN. s cr; cr; nextPutAll: (#SubjectPrefix << #security >> 'Subject: ') asString. idn := self subjectDN. i := 1. idn size timesRepeat: [s nextPutAll: (idn at: i) type getOIDDescription; nextPutAll: '='; nextPutAll: (idn at: i) value. i = idn size ifFalse: [s nextPutAll: ', ']. i := i + 1]. s cr; cr; nextPutAll: (#SubPubKeyAlgPrefix << #security >> 'Subject Public Key Algorithm: ') asString; nextPutAll: self subjectPublicKeyAlgorithmOID getDottedOID ; nextPutAll: ' ('; nextPutAll: self subjectPublicKeyAlgorithmOIDDescription; nextPutAll: ')'. s cr; cr; nextPutAll: (#SubPubKeyPrefix << #security >> 'Public Key:') asString. pk := self subjectPublicKeyInfo subjectPublicKey getBitStringAsFormattedHexStrings. s crtab; nextPutAll: pk. self extensions isNil ifFalse: [s cr; cr; nextPutAll: (#ExtensionsPrefix << #security >> 'EXTENSIONS:') asString. self extensions do: [:ext | s crtab; nextPutAll: ext id; nextPutAll: ' ('; nextPutAll: ext idDescription; nextPutAll: ')'. ext isCritical ifTrue: [s tab; nextPutAll: (#CRITICAL << #security >> 'CRITICAL') asString]]]. s cr; cr; nextPutAll: (#SignatureAlgorithmPrefix << #security >> 'Signature Algorithm: ') asString; nextPutAll: self signatureAlgorithmOID getDottedOID ; nextPutAll: ' ('; nextPutAll: self signatureAlgorithmOIDDescription; nextPutAll: ')'. s cr; cr; nextPutAll: (#SignaturePrefix << #security >> 'Signature:') asString. pk := self signature asFormattedHexStrings. s crtab; nextPutAll: pk. ^s contents
printOn: aStream aStream nextPutAll: 'X509v'; print: self version; nextPutAll: ': '; nextPutAll: (self subject commonName ifNil: ['No Common Name']); nextPutAll: ' <'; nextPutAll: (self issuer commonName ifNil:['No Common Name']); nextPut: $>
printOpenSSLOn: aStream indent: level "This should print the certificate in the format used by OpenSSL" aStream tab: level; nextPutAll: (#CertificatePrefix << #security >> 'Certificate:') asString; cr; tab: level + 1; nextPutAll: (#DataPrefix << #security >> 'Data:') asString; cr. self tbsCertificate printOpenSSLOn: aStream indent: level + 2. aStream tab: level + 1; nextPutAll: (#SignatureAlgorithmPrefix << #security >> 'Signature Algorithm: ') asString; nextPutAll: self signatureAlgorithm getOIDDescription; cr. signatureValue bytes printOpenSSLOn: aStream indent: level + 2 width: 18
</methods> <methods> Security.X509.Certificate <category>ssl</category>
isRSA ^self subjectPublicKeyAlgorithmOIDDescription = 'rsaEncryption'
</methods> <methods> Security.X509.Certificate <category>private</category>
badCertificate ^BadCertificate new messageText: (#SubjectSigAlgMismatch << #security >> 'Inner and outer signature algorithm identification does not match!'); parameter: self; isResumable: true; raiseSignal
invalidSignature ^InvalidSignature new messageText: (#InvalidSignature << #security >> 'Certificate signature is not valid!'); parameter: self; isResumable: true; raiseSignal
issuerMismatch: issuer ^IssuerMismatch new messageText: (#IssuerMismatch << #security >> 'Issuer does not match!'); parameter: issuer; isResumable: true; raiseSignal
</methods> <methods> Security.X509.Certificate <category>verification</category>
verifyIssuedBy: certificate "Verify that self is issued by certificate. Otherwise signal an error. " self issuerDNInBytes = certificate subjectDNInBytes ifFalse: [ self issuerMismatch: certificate ]. self verifySignedBy: certificate
verifySignedBy: certificate "Verify that the receiver is signed by certificate. Otherwise signal an error. " self signatureAlgorithmOID = self tbsSignatureAlgorithmOID ifFalse: [ self badCertificate. ^self ]. (self signatureAlgorithm verify: self isSignedBy: certificate) ifFalse: [ self invalidSignature ]
</methods> <methods> Security.X509.Certificate class <category>chain verification</category>
validateCertificateChain: anOrderedCollection ^X509Registry default validateCertificateChain: anOrderedCollection
</methods> <methods> Security.X509.Certificate class <category>instance creation</category>
fromBase64: aString "Read a certificate from Base64 encoded bytes" ^self fromBytes: (self decodeBase64: (self stripWhitespace: aString))
fromBytes: aByteArray | marshaler | marshaler := DERStream with: aByteArray. marshaler reset. ^marshaler unmarshalObjectType: ( ASN1Module find: #Certificate )
fromFile: aFile "Read a certificate from PEM formatted file" | file | file := aFile asFilename readStream. ^[ self fromString: file contents ] ensure: [ file close ]
fromString: aString "Reads a certificate from a PEM formatted file" ^(self getCertificateDataFrom: aString) ifNotNil: [ :b64 | self fromBase64: b64 ]
</methods> <methods> Security.X509.Certificate class <category>accessing</category>
asn1TypeName ^#Certificate
</methods> <methods> Security.X509.Certificate class <category>utilities</category>
getCertificateDataFrom: aPEMString "Answers the Base64 encoded certificate it the string has the appropriate delimiters required for PEM format; otherwise answers nil" | i j k | i := aPEMString indexOfSubCollection: '--BEGIN ' startingAt: 1 ifAbsent: [^nil]. i := aPEMString indexOfSubCollection: 'CERTIFICATE--' startingAt: i ifAbsent: [^nil]. j := aPEMString indexOfSubCollection: '--END ' startingAt: i ifAbsent: [^nil]. k := aPEMString indexOfSubCollection: 'CERTIFICATE--' startingAt: j ifAbsent: [^nil]. i := (aPEMString findEither: Character cr or: Character lf from: i to: k). ^(aPEMString copyFrom: i to: j) reject: [:c | c = $- or: [c isSeparator]]
</methods> <methods> Security.X509.Certificate class <category>initialize-release</category>
initialize self initializeAsn1Types
initializeAsn1Types " Certificate ::= SEQUENCE { tbsCertificate TBSCertificate, signatureAlgorithm AlgorithmIdentifier, signatureValue BIT STRING } " (ASN1Module SEQUENCE: self asn1TypeName) addElement: #tbsCertificate type: #TBSCertificate; addElement: #signatureAlgorithm type: #AlgorithmIdentifier; addElement: #signatureValue type: #BIT_STRING; mapping: self; retainEncoding: true
</methods> <methods> Security.DSAPrivateKey <category>x509</category>
asX509Key ^Security.X509.X509DSAPrivateKey new x: x; y: (g raisedTo: x modulo: p); p: p; q: q; g: g; yourself
x509AsAlgorithm ^DSA new privateKey: self; yourself
</methods> <methods> ASN1.ObjectIdentifier <category>x509 extensions</category>
getDottedOID |strm | strm := (String new:20) readWriteStream. self value do: [ :x | strm nextPutAll: x printString ] separatedBy: [ strm nextPut: $. ]. ^(strm contents copyFrom: 1 to: strm readPosition)
getOIDDescription ^self alphabeticSymbol asString
getOIDSymbol ^self getOIDSymbolForLookup
getOIDSymbolForLookup | strm | strm := (String new: 20) readWriteStream. strm nextPut: $x. self value do: [:x | strm nextPutAll: x printString] separatedBy: [strm nextPut: $x]. ^(strm contents copyFrom: 1 to: strm readPosition) asSymbol
getShortOIDDescription ^(self leafSymbol ifNil: [ self numericSymbol ]) asString
</methods> <methods> Security.DSA class <category>x509</category>
dsaOID ^ASN1.ObjectIdentifier value: #(1 2 840 10040 4 1)
</methods> <methods> Security.DSA <category>x509</category>
x509AlgorithmIdentifier ^Security.X509.AlgorithmIdentifier id_dsa_with_sha1
x509AlgorithmOID ^self class dsaOID
x509AsAlgorithm ^self
</methods> <methods> ASN1.TypeWrapper <category>x509</category>
asX509Name ^Security.X509.Name fromChoice: self
</methods> <methods> Core.ByteArray <category>security</category>
asFormattedHexStrings "(((#[160 11 2 16 255 0] asFormattedHexStrings)))" | lookup s ws | lookup := '0123456789ABCDEF'. s := String new: self size * 2. ws := s readWriteStream. self do: [ :b | ws nextPut: (lookup at: (b bitShift: -4) + 1). ws nextPut: (lookup at: (b bitAnd: 15) + 1). ws space ]. ^(ws contents copyFrom: 1 to: ws readPosition)
printOpenSSLOn: aStream indent: level width: bytes "This should print the value as a hex dump in the format used by OpenSSL" | digits | digits := '0123456789abcdef'. aStream tab: level. 1 to: self size do: [ :idx || byte | aStream nextPut: (digits at: ((byte := self at: idx) bitShift: -4) + 1). aStream nextPut: (digits at: (byte bitAnd: 16rF) + 1). idx = self size ifFalse: [ aStream nextPut: $:. idx \\ bytes = 0 ifTrue: [ aStream cr; tab: level ] ] ]. aStream cr
</methods> <methods> Security.RSAPublicKey <category>x509</category>
asX509Key ^self asX509PublicKey
asX509PublicKey ^Security.X509.X509RSAPublicKey new modulus: n; publicExponent: e; yourself
</methods> <methods> ASN1.Choice <category>x509</category>
asX509Name ^Security.X509.Name fromChoice: self
</methods> <methods> Security.DSAPublicKey <category>x509</category>
asX509Key ^self asX509PublicKey
asX509PublicKey ^Security.X509.X509DSAPublicKey new publicKey: y; dssParameters: (Security.X509.DSSParameters p: p q: q g: g); yourself
</methods> <methods> Security.RSA class <category>x509</category>
rsaEncryptionOID ^ASN1.ObjectIdentifier value: #(1 2 840 113549 1 1 1)
</methods> <methods> Security.RSA <category>x509</category>
x509AlgorithmIdentifier ^hash x509RSAAlgorithmIdentifier
x509AlgorithmOID ^self class rsaEncryptionOID
x509AsAlgorithm ^self
</methods> <methods> Security.RSAPrivateKey <category>x509</category>
asX509Key ^Security.X509.X509RSAPrivateKey new privateExponent: d; modulus: n; publicExponent: e; prime1: p; prime2: q; exponent1: self dp; exponent2: self dq; coefficient: self qInv; yourself
x509AsAlgorithm ^RSA new privateKey: self; yourself
</methods> <methods> Security.DSASignature <category>x509</category>
asX509Signature ^Security.X509.DSSSignatureValue new r: r; s: s; yourself
</methods> <methods> Security.MD5 <category>x509</category>
x509RSAAlgorithmIdentifier ^Security.X509.AlgorithmIdentifier md5WithRSAEncryption
</methods> <methods> Security.SHA <category>x509</category>
x509RSAAlgorithmIdentifier ^Security.X509.AlgorithmIdentifier sha_1WithRSAEncryption
</methods> <methods> ASN1.BitString <category>x509 extensions</category>
clearAllBits self bytes: (ByteArray new: self bytes size)
getBitStringAsFormattedHexStrings ^self value asFormattedHexStrings
</methods> <initialize> Security.X509.X509Object </initialize> <initialize> Security.X509.Validity </initialize> <initialize> Security.X509.Extension </initialize> <initialize> Security.X509.SubjectKeyIdentifier </initialize> <initialize> Security.X509.Name </initialize> <initialize> Security.X509.DSSParameters </initialize> <initialize> Security.X509.KeyUsage </initialize> <initialize> Security.X509.TBSCertificate </initialize> <initialize> Security.X509.X509DSAPublicKey </initialize> <initialize> Security.X509.DSSSignatureValue </initialize> <initialize> Security.X509.NoExtensionSupport </initialize> <initialize> Security.X509.AttributeValueAssertion </initialize> <initialize> Security.X509.X509RSAPublicKey </initialize> <initialize> Security.X509.BasicConstraints </initialize> <initialize> Security.X509.X509RSAPrivateKey </initialize> <initialize> Security.X509.AlgorithmIdentifier </initialize> <initialize> Security.X509.SubjectPublicKeyInfo </initialize> <initialize> Security.X509.X509DSAPrivateKey </initialize> <initialize> Security.X509.Certificate </initialize> "Imported Classes:" self error: 'Attempting to file-in parcel imports. Choose terminate or close' <class> <name>Object</name> <environment>Core</environment> <super></super> <private>false</private> none <imports></imports> <category>Kernel-Objects</category> <attributes> <package>Kernel-Objects</package> </attributes> </class> <class> <name>DSA</name> <environment>Security</environment> <super>Security.AsymmetricCipher</super> <private>false</private> none sha privateKey publicKey random random <imports></imports> <category>Security-Ciphers</category> <attributes> <package>DSA</package> </attributes> </class> <class> <name>TypeWrapper</name> <environment>ASN1</environment> <super>Protocols.MessageForwarder</super> <private>false</private> none encoding type <imports></imports> <category>ASN1</category> <attributes> <package>ASN1-Types</package> </attributes> </class> <class> <name>Choice</name> <environment>ASN1</environment> <super>ASN1.TypeWrapper</super> <private>false</private> none choice <imports></imports> <category>ASN1</category> <attributes> <package>ASN1-Types</package> </attributes> </class> <class> <name>RSA</name> <environment>Security</environment> <super>Security.AsymmetricCipher</super> <private>false</private> none privateKey publicKey hash <imports></imports> <category>Security-Ciphers</category> <attributes> <package>RSA</package> </attributes> </class> <class> <name>DSAPublicKey</name> <environment>Security</environment> <super>Security.DSAKey</super> <private>false</private> none y <imports></imports> <category>Security-Ciphers</category> <attributes> <package>DSA</package> </attributes> </class> <class> <name>ByteArray</name> <environment>Core</environment> <super>Core.IntegerArray</super> <private>false</private> bytes <imports></imports> <category>Collections-Arrayed</category> <attributes> <package>Collections-Arrayed</package> </attributes> </class> <class> <name>DSAPrivateKey</name> <environment>Security</environment> <super>Security.DSAKey</super> <private>false</private> none x <imports></imports> <category>Security-Ciphers</category> <attributes> <package>DSA</package> </attributes> </class> <class> <name>ObjectIdentifier</name> <environment>ASN1</environment> <super>ASN1.Imported</super> <private>false</private> none encoding <imports></imports> <category>ASN1</category> <attributes> <package>ASN1-Support</package> </attributes> </class> <class> <name>RSAPublicKey</name> <environment>Security</environment> <super>Security.RSAKey</super> <private>false</private> none e <imports></imports> <category>Security-Ciphers</category> <attributes> <package>RSA</package> </attributes> </class> <class> <name>SHA</name> <environment>Security</environment> <super>Security.SHAHash</super> <private>false</private> none t k <imports></imports> <category>Security-Hashes</category> <attributes> <package>SHA</package> </attributes> </class> <class> <name>BitString</name> <environment>ASN1</environment> <super>ASN1.Imported</super> <private>false</private> none unused <imports></imports> <category>ASN1</category> <attributes> <package>ASN1-Support</package> </attributes> </class> <class> <name>Exception</name> <environment>Core</environment> <super>Core.GenericException</super> <private>false</private> none <imports></imports> <category>Kernel-Exception Handling</category> <attributes> <package>Kernel-Exception Handling</package> </attributes> </class> <class> <name>MD5</name> <environment>Security</environment> <super>Security.Hash</super> <private>false</private> none a b c d aa bb cc dd f ff m <imports></imports> <category>Security-Hashes</category> <attributes> <package>MD5</package> </attributes> </class> <class> <name>RSAPrivateKey</name> <environment>Security</environment> <super>Security.RSAKey</super> <private>false</private> none d e p q dP dQ qInv otherFactors <imports></imports> <category>Security-Ciphers</category> <attributes> <package>RSA</package> </attributes> </class> <class> <name>DSASignature</name> <environment>Security</environment> <super>Core.Object</super> <private>false</private> none r s <imports></imports> <category>Security-Ciphers</category> <attributes> <package>DSA</package> </attributes> </class>