LEFT | RIGHT |
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 "bytes" | 8 "bytes" |
| 9 "code.google.com/p/go.crypto/openpgp/errors" |
| 10 "code.google.com/p/go.crypto/openpgp/s2k" |
9 "crypto/cipher" | 11 "crypto/cipher" |
10 "crypto/openpgp/errors" | |
11 "crypto/openpgp/s2k" | |
12 "io" | 12 "io" |
13 "strconv" | 13 "strconv" |
14 ) | 14 ) |
15 | 15 |
16 // This is the largest session key that we'll support. Since no 512-bit cipher | 16 // This is the largest session key that we'll support. Since no 512-bit cipher |
17 // has even been seriously used, this is comfortably large. | 17 // has even been seriously used, this is comfortably large. |
18 const maxSessionKeySizeInBytes = 64 | 18 const maxSessionKeySizeInBytes = 64 |
19 | 19 |
20 // SymmetricKeyEncrypted represents a passphrase protected session key. See RFC | 20 // SymmetricKeyEncrypted represents a passphrase protected session key. See RFC |
21 // 4880, section 5.3. | 21 // 4880, section 5.3. |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 c.XORKeyStream(encryptedCipherAndKey, buf[1:]) | 152 c.XORKeyStream(encryptedCipherAndKey, buf[1:]) |
153 c.XORKeyStream(encryptedCipherAndKey[1:], sessionKey) | 153 c.XORKeyStream(encryptedCipherAndKey[1:], sessionKey) |
154 _, err = w.Write(encryptedCipherAndKey) | 154 _, err = w.Write(encryptedCipherAndKey) |
155 if err != nil { | 155 if err != nil { |
156 return | 156 return |
157 } | 157 } |
158 | 158 |
159 key = sessionKey | 159 key = sessionKey |
160 return | 160 return |
161 } | 161 } |
LEFT | RIGHT |