LEFT | RIGHT |
(no file at all) | |
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 "big" | 8 "big" |
9 "crypto/dsa" | 9 "crypto/dsa" |
10 "crypto/openpgp/error" | 10 "crypto/openpgp/error" |
11 "crypto/rsa" | 11 "crypto/rsa" |
12 "crypto/sha1" | 12 "crypto/sha1" |
13 "encoding/binary" | 13 "encoding/binary" |
14 "hash" | 14 "hash" |
15 "io" | 15 "io" |
16 "os" | 16 "os" |
17 ) | 17 ) |
18 | 18 |
19 // PublicKey represents an OpenPGP public key. See RFC 4880, section 5.5.2. | 19 // PublicKey represents an OpenPGP public key. See RFC 4880, section 5.5.2. |
20 type PublicKey struct { | 20 type PublicKey struct { |
21 CreationTime uint32 // seconds since the epoch | 21 CreationTime uint32 // seconds since the epoch |
22 PubKeyAlgo PublicKeyAlgorithm | 22 PubKeyAlgo PublicKeyAlgorithm |
23 PublicKey interface{} // Either a *rsa.PublicKey or *dsa.PublicKey | 23 PublicKey interface{} // Either a *rsa.PublicKey or *dsa.PublicKey |
24 Fingerprint [20]byte | 24 Fingerprint [20]byte |
25 KeyId uint64 | 25 KeyId uint64 |
26 » IsSubKey bool | 26 » IsSubkey bool |
27 | 27 |
28 n, e, p, q, g, y parsedMPI | 28 n, e, p, q, g, y parsedMPI |
29 } | 29 } |
30 | 30 |
31 func (pk *PublicKey) parse(r io.Reader) (err os.Error) { | 31 func (pk *PublicKey) parse(r io.Reader) (err os.Error) { |
32 // RFC 4880, section 5.5.2 | 32 // RFC 4880, section 5.5.2 |
33 var buf [6]byte | 33 var buf [6]byte |
34 _, err = readFull(r, buf[:]) | 34 _, err = readFull(r, buf[:]) |
35 if err != nil { | 35 if err != nil { |
36 return | 36 return |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 // given Writer. | 251 // given Writer. |
252 func writeMPIs(w io.Writer, mpis ...parsedMPI) (err os.Error) { | 252 func writeMPIs(w io.Writer, mpis ...parsedMPI) (err os.Error) { |
253 for _, mpi := range mpis { | 253 for _, mpi := range mpis { |
254 err = writeMPI(w, mpi.bitLength, mpi.bytes) | 254 err = writeMPI(w, mpi.bitLength, mpi.bytes) |
255 if err != nil { | 255 if err != nil { |
256 return | 256 return |
257 } | 257 } |
258 } | 258 } |
259 return | 259 return |
260 } | 260 } |
LEFT | RIGHT |