don't die if blksize is too large; clamp it to max allowed.
This commit is contained in:
parent
fbfcd37679
commit
0ba5c8b599
1 changed files with 7 additions and 5 deletions
|
@ -79,13 +79,15 @@ type Encryptor struct {
|
||||||
// signing any recipient keys. If 'sk' is nil, then ephmeral Curve25519 keys
|
// signing any recipient keys. If 'sk' is nil, then ephmeral Curve25519 keys
|
||||||
// are generated and used with recipient's public key.
|
// are generated and used with recipient's public key.
|
||||||
func NewEncryptor(sk *PrivateKey, blksize uint64) (*Encryptor, error) {
|
func NewEncryptor(sk *PrivateKey, blksize uint64) (*Encryptor, error) {
|
||||||
if blksize >= uint64(maxChunkSize) {
|
var blksz uint32
|
||||||
return nil, fmt.Errorf("encrypt: Blocksize is too large (max 16M)")
|
|
||||||
}
|
|
||||||
|
|
||||||
blksz := uint32(blksize)
|
switch {
|
||||||
if blksz == 0 {
|
case blksize == 0:
|
||||||
blksz = chunkSize
|
blksz = chunkSize
|
||||||
|
case blksize > uint64(maxChunkSize):
|
||||||
|
blksz = maxChunkSize
|
||||||
|
default:
|
||||||
|
blksz = uint32(blksize)
|
||||||
}
|
}
|
||||||
|
|
||||||
e := &Encryptor{
|
e := &Encryptor{
|
||||||
|
|
Loading…
Add table
Reference in a new issue