whisper: minor update

This commit is contained in:
Vlad 2018-01-11 20:46:05 +02:00
parent aa1a72fae4
commit 70f1dd9666
2 changed files with 8 additions and 2 deletions

View file

@ -465,6 +465,6 @@ func TestAesNonce(t *testing.T) {
// This is the most important single test in this package. // This is the most important single test in this package.
// If it fails, whisper will not be working. // If it fails, whisper will not be working.
if aesgcm.NonceSize() != aesNonceLength { if aesgcm.NonceSize() != aesNonceLength {
t.Fatalf("Nonce size is wrong. This is a critical error. Apparently AES nonce size have changed in the new version of AES GCM package. Whisper will not be working untill this problem is resolved.") t.Fatalf("Nonce size is wrong. This is a critical error. Apparently AES nonce size have changed in the new version of AES GCM package. Whisper will not be working until this problem is resolved.")
} }
} }

View file

@ -984,7 +984,13 @@ func validatePrivateKey(k *ecdsa.PrivateKey) bool {
// validateSymmetricKey returns false if the key contains all zeros, // validateSymmetricKey returns false if the key contains all zeros,
// which is a simplest and the most common bug. // which is a simplest and the most common bug.
func validateRandomData(k []byte, expectedSize int) bool { func validateRandomData(k []byte, expectedSize int) bool {
return len(k) == expectedSize && !containsOnlyZeros(k) if len(k) != expectedSize {
return false
}
if expectedSize > 4 && containsOnlyZeros(k) {
return false
}
return true
} }
// containsOnlyZeros checks if the data contain only zeros. // containsOnlyZeros checks if the data contain only zeros.