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

Delta Between Two Patch Sets: openpgp/packet/config.go

Issue 12685044: code review 12685044: openpgp: Implement compressed data packets & add suppor...
Left Patch Set: diff -r 1747226a2f43 https://code.google.com/p/go.crypto Created 10 years, 7 months ago
Right Patch Set: diff -r 1747226a2f43 https://code.google.com/p/go.crypto Created 10 years, 7 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
LEFTRIGHT
1 // Copyright 2012 The Go Authors. All rights reserved. 1 // Copyright 2012 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 "crypto" 8 "crypto"
9 "crypto/rand" 9 "crypto/rand"
10 "io" 10 "io"
(...skipping 12 matching lines...) Expand all
23 // DefaultCipher is the cipher to be used. 23 // DefaultCipher is the cipher to be used.
24 // If zero, AES-128 is used. 24 // If zero, AES-128 is used.
25 DefaultCipher CipherFunction 25 DefaultCipher CipherFunction
26 // Time returns the current time as the number of seconds since the 26 // Time returns the current time as the number of seconds since the
27 // epoch. If Time is nil, time.Now is used. 27 // epoch. If Time is nil, time.Now is used.
28 Time func() time.Time 28 Time func() time.Time
29 // DefaultCompressionAlgo is the compression algorithm to be 29 // DefaultCompressionAlgo is the compression algorithm to be
30 // applied to the plaintext before encryption. If zero, no 30 // applied to the plaintext before encryption. If zero, no
31 // compression is done. 31 // compression is done.
32 DefaultCompressionAlgo CompressionAlgo 32 DefaultCompressionAlgo CompressionAlgo
33 » // DefaultCompressionConfig configures the compression 33 » // CompressionConfig configures the compression settings.
34 » // settings. CompressionConfig.Level must be set to between -1 34 » CompressionConfig *CompressionConfig
35 » // and 9, otherwise a non-nil error will be returned during
36 » // encryption. A -1 value for CompressConfig.Level causes the
37 » // default compression level to be used, 0 means no
38 » // compression (the compressor will store the data as-is) and
39 » // 1 to 9 cause increasing (better, slower) compression levels
40 » // to be used (See the constants above for convenient common
41 » // settings). If nil and compression is in effect,
42 » // DefaultCompression is the level of compression used.
43 » DefaultCompressionConfig *CompressionConfig
agl1 2013/08/12 11:43:41 While other members of Config are defaults and can
44 } 35 }
45 36
46 func (c *Config) Random() io.Reader { 37 func (c *Config) Random() io.Reader {
47 if c == nil || c.Rand == nil { 38 if c == nil || c.Rand == nil {
48 return rand.Reader 39 return rand.Reader
49 } 40 }
50 return c.Rand 41 return c.Rand
51 } 42 }
52 43
53 func (c *Config) Hash() crypto.Hash { 44 func (c *Config) Hash() crypto.Hash {
(...skipping 16 matching lines...) Expand all
70 } 61 }
71 return c.Time() 62 return c.Time()
72 } 63 }
73 64
74 func (c *Config) Compression() CompressionAlgo { 65 func (c *Config) Compression() CompressionAlgo {
75 if c == nil { 66 if c == nil {
76 return CompressionNone 67 return CompressionNone
77 } 68 }
78 return c.DefaultCompressionAlgo 69 return c.DefaultCompressionAlgo
79 } 70 }
80
81 func (c *Config) CompressionLevel() int {
82 if c == nil || c.DefaultCompressionConfig == nil {
83 return DefaultCompression
84 }
85
86 return c.DefaultCompressionConfig.Level
87 }
LEFTRIGHT

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