|
|
@ -151,11 +151,11 @@ func encrypt(key []byte, plaintext []byte, additionalData []byte) ([]byte, []byt |
|
|
|
return nil, nil, err |
|
|
|
return nil, nil, err |
|
|
|
} |
|
|
|
} |
|
|
|
aesgcm, err := cipher.NewGCM(block) |
|
|
|
aesgcm, err := cipher.NewGCM(block) |
|
|
|
nonce := make([]byte, aesgcm.NonceSize()) |
|
|
|
if err != nil { |
|
|
|
if _, err := io.ReadFull(rand.Reader, nonce); err != nil { |
|
|
|
|
|
|
|
return nil, nil, err |
|
|
|
return nil, nil, err |
|
|
|
} |
|
|
|
} |
|
|
|
if err != nil { |
|
|
|
nonce := make([]byte, aesgcm.NonceSize()) |
|
|
|
|
|
|
|
if _, err := io.ReadFull(rand.Reader, nonce); err != nil { |
|
|
|
return nil, nil, err |
|
|
|
return nil, nil, err |
|
|
|
} |
|
|
|
} |
|
|
|
ciphertext := aesgcm.Seal(nil, nonce, plaintext, additionalData) |
|
|
|
ciphertext := aesgcm.Seal(nil, nonce, plaintext, additionalData) |
|
|
|