OLD | NEW |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package packet | 5 package packet |
6 | 6 |
7 import ( | 7 import ( |
8 "code.google.com/p/go.crypto/openpgp/elgamal" | 8 "code.google.com/p/go.crypto/openpgp/elgamal" |
9 "code.google.com/p/go.crypto/openpgp/errors" | 9 "code.google.com/p/go.crypto/openpgp/errors" |
10 "crypto/dsa" | 10 "crypto/dsa" |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 if len(hashBytes) > subgroupSize { | 311 if len(hashBytes) > subgroupSize { |
312 hashBytes = hashBytes[:subgroupSize] | 312 hashBytes = hashBytes[:subgroupSize] |
313 } | 313 } |
314 if !dsa.Verify(dsaPublicKey, hashBytes, new(big.Int).SetBytes(si
g.DSASigR.bytes), new(big.Int).SetBytes(sig.DSASigS.bytes)) { | 314 if !dsa.Verify(dsaPublicKey, hashBytes, new(big.Int).SetBytes(si
g.DSASigR.bytes), new(big.Int).SetBytes(sig.DSASigS.bytes)) { |
315 return errors.SignatureError("DSA verification failure") | 315 return errors.SignatureError("DSA verification failure") |
316 } | 316 } |
317 return nil | 317 return nil |
318 default: | 318 default: |
319 panic("shouldn't happen") | 319 panic("shouldn't happen") |
320 } | 320 } |
321 panic("unreachable") | |
322 } | 321 } |
323 | 322 |
324 // keySignatureHash returns a Hash of the message that needs to be signed for | 323 // keySignatureHash returns a Hash of the message that needs to be signed for |
325 // pk to assert a subkey relationship to signed. | 324 // pk to assert a subkey relationship to signed. |
326 func keySignatureHash(pk, signed *PublicKey, sig *Signature) (h hash.Hash, err e
rror) { | 325 func keySignatureHash(pk, signed *PublicKey, sig *Signature) (h hash.Hash, err e
rror) { |
327 h = sig.Hash.New() | 326 h = sig.Hash.New() |
328 if h == nil { | 327 if h == nil { |
329 return nil, errors.UnsupportedError("hash function") | 328 return nil, errors.UnsupportedError("hash function") |
330 } | 329 } |
331 | 330 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 bitLength = pk.n.bitLength | 419 bitLength = pk.n.bitLength |
421 case PubKeyAlgoDSA: | 420 case PubKeyAlgoDSA: |
422 bitLength = pk.p.bitLength | 421 bitLength = pk.p.bitLength |
423 case PubKeyAlgoElGamal: | 422 case PubKeyAlgoElGamal: |
424 bitLength = pk.p.bitLength | 423 bitLength = pk.p.bitLength |
425 default: | 424 default: |
426 err = errors.InvalidArgumentError("bad public-key algorithm") | 425 err = errors.InvalidArgumentError("bad public-key algorithm") |
427 } | 426 } |
428 return | 427 return |
429 } | 428 } |
OLD | NEW |