LEFT | RIGHT |
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 Loading... |
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 Loading... |
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 } |
LEFT | RIGHT |