Skip to content

Commit

Permalink
feature(exts): AuthorityKeyIdentifier now asserts that the serial n…
Browse files Browse the repository at this point in the history
…umber is non-negative
  • Loading branch information
kdubb committed Sep 16, 2021
1 parent c73776f commit 0fe8c3a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions Sources/ShieldX509/ExtensionAuthorityKeyIdentifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public struct AuthorityKeyIdentifier: Equatable, Hashable, Codable, NonCriticalE
authorityCertIssuer: GeneralNames? = nil,
authorityCertSerialNumber: TBSCertificate.SerialNumber? = nil
) {
precondition(authorityCertSerialNumber?.sign != .minus)
self.keyIdentifier = keyIdentifier
self.authorityCertIssuer = authorityCertIssuer
self.authorityCertSerialNumber = authorityCertSerialNumber
Expand Down
2 changes: 1 addition & 1 deletion Tests/CertificateBuilderECTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class CertificateBuilderECTests: XCTestCase {
.authorityKeyIdentifier(
Digester.digest(Self.keyPair.encodedPublicKey(), using: .sha1),
certIssuer: [.dnsName("github.com/outfoxx/Shield/CA")],
certSerialNumber: Integer(sign: .plus, magnitude: .randomInteger(withExactWidth: 19 * 8))
certSerialNumber: Certificate.Builder.randomSerialNumber()
)
.computeSubjectKeyIdentifier()
.valid(for: 86400 * 365)
Expand Down
2 changes: 1 addition & 1 deletion Tests/CertificateBuilderRSATests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class CertificateBuilderRSATests: XCTestCase {
.authorityKeyIdentifier(
Digester.digest(Self.keyPair.encodedPublicKey(), using: .sha1),
certIssuer: [.dnsName("github.com/outfoxx/Shield/CA")],
certSerialNumber: Integer(sign: .plus, magnitude: .randomInteger(withExactWidth: 19 * 8))
certSerialNumber: Certificate.Builder.randomSerialNumber()
)
.computeSubjectKeyIdentifier()
.valid(for: 86400 * 365)
Expand Down

1 comment on commit 0fe8c3a

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage for this commit

73.14%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
Sources/ShieldCrypto
   Cryptor.swift78.02%100%65.79%79.40%114, 126–136, 138–140, 142–144, 146–150, 168, 173–177, 193, 198–208, 239, 47, 61, 66–68, 98
   Digest.swift87.50%100%84.21%88.31%172–174, 176–178, 207–209
   Errors.swift0%100%0%0%18–20
   HMAC.swift94.57%100%88.89%95.50%44, 48–50
   PBKDF.swift91.45%100%77.78%92.59%112, 34–36, 56–58, 86
   Random.swift94.74%100%100%94.12%22
Sources/ShieldOID
   OIDs.swift77.22%100%72.22%78.69%53, 63–64, 71, 77–79, 81–83
Sources/ShieldPKCS
   RSAPrivateKey.swift100%100%100%100%
   RSAPublicKey.swift100%100%100%100%
Sources/ShieldSecurity
   AlgorithmIdentifier.swift82.67%100%66.67%83.33%33, 35, 39, 41, 43, 50, 52, 56, 58, 60, 88
   Certificate.swift74.19%100%75%74.07%28–34
   CertificationRequest.swift77.14%100%75%77.42%27–33
   SecCertificate.swift36.96%100%21.05%38.39%106, 112–114, 143, 151–165, 171–184, 190–203, 205–212, 218–234, 240–256, 36–41, 43–45, 53, 57–60, 68, 72–75, 84, 89, 96
   SecIdentity.swift92.41%100%100%91.78%101, 42, 56–57, 79, 90
   SecKey.swift83.76%100%73.33%84.62%110, 121, 130, 141, 154, 175–179, 195, 215, 219, 239–241, 263, 267, 287–289, 363, 380, 430–438, 47–49, 498, 50–51, 511–514, 52–54, 56–58, 73, 76, 91, 94
   SecKeyPair.swift79%100%57.14%81.31%101, 148–152, 282–286, 288–289, 29, 290–292, 30–36, 38–40, 59–61, 63–65, 81, 87
   SecKeyType.swift95%100%100%94.44%28
Sources/ShieldX500
   AttributeTypeAndValue.swift55.93%100%38.46%60.87%104–106, 51–53, 55–57, 84–88
   AttributeValueHandlers.swift29.63%100%21.43%32.50%35–38, 47–50, 52–56, 58–61, 63–66
   DistinguishedNameBuilder.swift67.80%100%81.82%64.58%32–34, 36–48, 61
   DistinguishedNameStringComposer.swift76.42%100%72.73%76.84%100–107, 61–63, 65–70, 85–86, 93, 99
   DistinguishedNameStringParser.swift82.67%100%84.62%82.54%104–112, 121–122, 128, 167–169, 171–174, 189–196, 48, 51, 55, 89–91
   NamingStyles.swift87.72%100%85.71%88.37%127, 131, 31, 51, 54
   RelativeDistinguishedName.swift50%100%50%50%24–26, 33–35
Sources/ShieldX509
   AlgorithmIdentifier.swift75%100%66.67%76.92%35–37
   AttributeValueHandlers.swift59.09%100%50%62.50%33–36
   Attributes.swift53.40%100%48.48%54.43%100–103, 108, 111, 118–120, 126–128, 142–145, 152–155, 169–171, 180–182, 229–237, 256–257, 259–261, 263, 70–79, 81–93, 95–99
   CRAttributes.swift66.67%100%50%75%
   Certificate.swift100%100%100%100%
   CertificateBuilder.swift71.50%100%65.96%72.18%112–129, 166–178, 180–197, 257, 337–353, 355–367, 434, 452–454, 84–96
   CertificationRequest.swift100%100%100%100%
   CertificationRequestBuilder.swift73%100%58.82%75.90%37–39, 41–52
   CertificationRequestInfo.swift100%100%100%100%
   DirectoryNames.swift31.82%100%25%33.33%22–30, 32–35, 80–82
   ExtensionAuthorityKeyIdentifier.swift100%100%100%100%
   ExtensionBasicConstraints.swift100%100%100%100%
   ExtensionExtKeyUsage.swift50%100%50%50%43–50
   ExtensionIssuerAlternativeName.swift50%100%50%50%42–49
   ExtensionKeyUsage.swift100%100%100%100%
   ExtensionSubjectAlternativeName.swift90.91%100%75%94.44%
   ExtensionSubjectKeyIdentifier.swift64.29%100%66.67%63.64%30–33
   Extensions.swift71.74%100%65.63%73.58%100–102, 113–116, 184–185, 191–193, 195, 42–46, 66–70
   GeneralName.swift24.80%100%50%23.97%104–138, 140–179, 32–33, 35–36, 41–42, 44–45, 47–48, 50–51, 53–54, 56–57, 59
   Name.swift100%100%100%100%
   SubjectPublicKeyInfo.swift71.43%100%50%80%30
   TBSCertificate.swift100%100%100%100%

Please sign in to comment.