Set len to 0 on init
This commit is contained in:
parent
01792a7f59
commit
43d94fdf50
|
@ -12,7 +12,7 @@ const noncesize int = 16
|
|||
func Encrypt(key []byte, plaintext []byte, additionalData []byte) ([]byte, error) {
|
||||
|
||||
cipher := make([]byte, len(plaintext)+abytes+noncesize)
|
||||
var cipherlen uint64
|
||||
var cipherlen uint64 = (uint64)(len(cipher))
|
||||
nonce := genNonce()
|
||||
ret := romulus_m_encrypt(
|
||||
cipher[noncesize:],
|
||||
|
@ -30,13 +30,13 @@ func Encrypt(key []byte, plaintext []byte, additionalData []byte) ([]byte, error
|
|||
return nil, errors.New("Failed to decrypt")
|
||||
}
|
||||
copy(cipher, nonce)
|
||||
return cipher[:cipherlen], nil
|
||||
return cipher[:(int)(cipherlen)+noncesize], nil
|
||||
}
|
||||
|
||||
func Decrypt(key []byte, ciphertext []byte, additionalData []byte) ([]byte, bool, error) {
|
||||
|
||||
plaintext := make([]byte, len(ciphertext))
|
||||
var plaintextLen uint64
|
||||
var plaintextLen uint64 = (uint64)(len(plaintext))
|
||||
ret := romulus_m_decrypt(
|
||||
plaintext,
|
||||
&plaintextLen,
|
||||
|
|
|
@ -439,9 +439,7 @@ func romulus_m_decrypt(m []byte, mlen *uint64, nsec []byte, c []byte, clen uint6
|
|||
|
||||
reset_lfsr_gf56(CNT[:])
|
||||
|
||||
for i = 0; i < 16; i++ {
|
||||
T[i] = (c[clen-16+uint64(i):])[0]
|
||||
}
|
||||
copy(T[:], c[len(c)-len(T):])
|
||||
|
||||
for i = 0; i < n; i = i + 1 {
|
||||
s[i] = T[i]
|
||||
|
|
Loading…
Reference in New Issue