veraison / go-cose

go library for CBOR Object Signing and Encryption (COSE)
Mozilla Public License 2.0
49 stars 26 forks source link

Make built-in types implement the new DigestSigner and DigestVerify interface #144

Closed qmuntal closed 1 year ago

qmuntal commented 1 year ago

Fixes #120

codecov[bot] commented 1 year ago

Codecov Report

Merging #144 (5548b0a) into main (2f778da) will increase coverage by 2.79%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #144      +/-   ##
==========================================
+ Coverage   91.05%   93.84%   +2.79%     
==========================================
  Files          12       12              
  Lines        1542     1900     +358     
==========================================
+ Hits         1404     1783     +379     
+ Misses        101       82      -19     
+ Partials       37       35       -2     
Impacted Files Coverage Δ
signer.go 100.00% <ø> (ø)
verifier.go 100.00% <ø> (ø)
ecdsa.go 96.25% <100.00%> (+0.35%) :arrow_up:
rsa.go 100.00% <100.00%> (ø)

... and 3 files with indirect coverage changes

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

yogeshbdeshpande commented 1 year ago

@qmuntal as mentioned in the meeting, please add the README explaining the new API

qmuntal commented 1 year ago

@qmuntal as mentioned in the meeting, please add the README explaining the new API

Done.

SteveLasker commented 1 year ago

@yogeshbdeshpande, @shizhMSFT, @ivarprudnikov, @setrofim can you PTAL

ivarprudnikov commented 1 year ago

Unit tests would be necessary to prove it works.

  1. Create a keypair (both for RSA and ECDSA), then for each
  2. Create a signer, cast it to DigestSigner and sign some "foobar" digest
  3. Create a verifier, cast it to DigestVerifier and verify the signature along with the digest

Otherwise it looks OK

OR13 commented 1 year ago

You might want your test strings to include some nasty unicode, unless you use some standard test strings from some the RFCs

qmuntal commented 1 year ago

Unit tests would be necessary to prove it works.

  1. Create a keypair (both for RSA and ECDSA), then for each
  2. Create a signer, cast it to DigestSigner and sign some "foobar" digest
  3. Create a verifier, cast it to DigestVerifier and verify the signature along with the digest

Otherwise it looks OK

You might want your test strings to include some nasty unicode, unless you use some standard test strings from some the RFCs

@ivarprudnikov @OR13 done. I initially didn't add any test case because the built-in signers/verifiers are internally implemented in terms of DigestSigner and DigestVerifier, therefore the existing test coverage already applies to the new interfaces. I've added some basic tests, as suggested, to be more explicit.