Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make NIST PublicKeys conform to Hashable #176

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Sajjon
Copy link
Contributor

@Sajjon Sajjon commented Apr 18, 2023

Make ALL NIST PublicKeys conform to Hashable

N.B. Merge open PR #174 first (or if #174 is closed, close this one too), since this PR builds on top of that.

Checklist

  • I've run tests to see all new and existing tests pass
  • I've followed the code style of the rest of the project
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary

If you've made changes to gyb files

  • I've run .script/generate_boilerplate_files_with_gyb and included updated generated files in a commit of this pull request

Motivation:

This is the NIST analogue counterpart of #175, so the motivation put in there applies here as well.

This PR is an addition of open PR #174.

Modifications:

  1. Make P256, P384 and P521's Signing and KeyAgreement PublicKey be Hashable, by...
  2. ... marking NISTECPublicKey to be Hashable and adding hash:into function in ECDH.swift.gyb
  3. Add tests for these.

Result:

ALL NIST PublicKey's now conform to Hashable

@@ -88,6 +88,14 @@ extension P256 {
let pemDocument = ASN1.PEMDocument(type: "PUBLIC KEY", derBytes: self.derRepresentation)
return pemDocument.pemString
}

public static func ==(lhs: Self, rhs: Self) -> Bool {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Equatable, Part of #174 but I was unable to create a diff between just this PR and the source branch of that PR.

@@ -94,6 +94,14 @@ extension ${CURVE} {
let pemDocument = ASN1.PEMDocument(type: "PUBLIC KEY", derBytes: self.derRepresentation)
return pemDocument.pemString
}

public static func ==(lhs: Self, rhs: Self) -> Bool {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Equatable, Part of #174 but I was unable to create a diff between just this PR and the source branch of that PR.

@@ -453,6 +453,138 @@ class SignatureTests: XCTestCase {
let compressedX963Positive = Data(base64Encoded: "A+QHCXtGd5WWSQgp37FBPXMy+nnSwFK79QQD0ZeNMv7L")!
XCTAssertThrowsError(try P256.Signing.PublicKey(x963Representation: compressedX963Positive))
}


func testP256SigningPublicKeyEquatable() throws {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Equatable, Part of #174 but I was unable to create a diff between just this PR and the source branch of that PR.

Copy link
Collaborator

@Lukasa Lukasa left a comment

Choose a reason for hiding this comment

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

Blocking for future CryptoKit updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants