Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(463)

Delta Between Two Patch Sets: src/pkg/crypto/rsa/pssvect_test.go

Issue 9438043: code review 9438043: rsa: Implementation of RSASSA-PSS signature algorithm a...
Left Patch Set: diff -r 1abed5873071 https://code.google.com/p/go Created 10 years, 10 months ago
Right Patch Set: diff -r 1abed5873071 https://code.google.com/p/go Created 10 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/crypto/rsa/pss.go ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 package rsa 1 package rsa
2 2
3 // Test cases from: 3 // Test cases from:
4 // ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-1/pkcs-1v2-1-vec.zip 4 // ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-1/pkcs-1v2-1-vec.zip
5 import ( 5 import (
6 "bytes" 6 "bytes"
7 "crypto" 7 "crypto"
8 "crypto/rand" 8 "crypto/rand"
9 "crypto/sha1" 9 "crypto/sha1"
10 "math/big" 10 "math/big"
(...skipping 29 matching lines...) Expand all
40 hash.Write(msg) 40 hash.Write(msg)
41 hashed = hash.Sum(hashed[:0]) 41 hashed = hash.Sum(hashed[:0])
42 42
43 s, err := signPSSWithSalt(rand.Reader, priv, crypto.SHA1, hashed, salt) 43 s, err := signPSSWithSalt(rand.Reader, priv, crypto.SHA1, hashed, salt)
44 if err != nil { 44 if err != nil {
45 t.Error("Error: ", err) 45 t.Error("Error: ", err)
46 } 46 }
47 if !bytes.Equal(s, sig) { 47 if !bytes.Equal(s, sig) {
48 t.Error("Wrong Signature") 48 t.Error("Wrong Signature")
49 } 49 }
50 » err = VerifyPSS(&priv.PublicKey, crypto.SHA1, hashed, s, len(salt)) 50 » err = verifyPSSWithSalt(&priv.PublicKey, crypto.SHA1, hashed, s, len(sal t))
51 if err != nil { 51 if err != nil {
52 t.Errorf("Bad Verification") 52 t.Errorf("Bad Verification")
53 } 53 }
54 } 54 }
55 55
56 func TestPSSSign_Example_10_3(t *testing.T) { 56 func TestPSSSign_Example_10_3(t *testing.T) {
57 // Example 10.3 in pss-vect.txt from 57 // Example 10.3 in pss-vect.txt from
58 // ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-1/pkcs-1v2-1-vec.zip 58 // ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-1/pkcs-1v2-1-vec.zip
59 priv := &PrivateKey{ 59 priv := &PrivateKey{
60 PublicKey: PublicKey{ 60 PublicKey: PublicKey{
(...skipping 15 matching lines...) Expand all
76 hash.Write(msg) 76 hash.Write(msg)
77 hashed = hash.Sum(hashed[:0]) 77 hashed = hash.Sum(hashed[:0])
78 78
79 s, err := signPSSWithSalt(rand.Reader, priv, crypto.SHA1, hashed, salt) 79 s, err := signPSSWithSalt(rand.Reader, priv, crypto.SHA1, hashed, salt)
80 if err != nil { 80 if err != nil {
81 t.Error("Error: ", err) 81 t.Error("Error: ", err)
82 } 82 }
83 if !bytes.Equal(s, sig) { 83 if !bytes.Equal(s, sig) {
84 t.Error("Wrong Signature") 84 t.Error("Wrong Signature")
85 } 85 }
86 » err = VerifyPSS(&priv.PublicKey, crypto.SHA1, hashed, s, len(salt)) 86 » err = verifyPSSWithSalt(&priv.PublicKey, crypto.SHA1, hashed, s, len(sal t))
87 if err != nil { 87 if err != nil {
88 t.Errorf("Bad Verification") 88 t.Errorf("Bad Verification")
89 } 89 }
90 } 90 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b