diff --git a/whisper/whisperv5/doc.go b/whisper/whisperv5/doc.go index c37bcb9263..223d8246ee 100644 --- a/whisper/whisperv5/doc.go +++ b/whisper/whisperv5/doc.go @@ -51,10 +51,11 @@ const ( paddingMask = byte(3) signatureFlag = byte(4) - TopicLength = 4 - signatureLength = 65 - aesKeyLength = 32 - saltLength = 12 + TopicLength = 4 + signatureLength = 65 + aesKeyLength = 32 + saltLength = 12 + AESNonceMaxLength = 12 MaxMessageLength = 0xFFFF // todo: remove this restriction after testing in morden and analizing stats. this should be regulated by MinimumPoW. MinimumPoW = 10.0 // todo: review diff --git a/whisper/whisperv5/envelope.go b/whisper/whisperv5/envelope.go index cb8fc89d19..6835e22c03 100644 --- a/whisper/whisperv5/envelope.go +++ b/whisper/whisperv5/envelope.go @@ -131,7 +131,7 @@ func (e *Envelope) calculatePoW(diff uint32) { h = crypto.Keccak256(buf) firstBit := common.FirstBitSet(common.BigD(h)) x := math.Pow(2, float64(firstBit)) - x /= float64(len(e.Data) + len(e.Salt) + len(e.AESNonce)) + x /= float64(len(e.Data)) // we only count e.Data, other variable-sized members are checked in Whisper.add() x /= float64(e.TTL + diff) e.pow = x } diff --git a/whisper/whisperv5/whisper.go b/whisper/whisperv5/whisper.go index 3402c7bf66..8a9770fdd0 100644 --- a/whisper/whisperv5/whisper.go +++ b/whisper/whisperv5/whisper.go @@ -419,7 +419,7 @@ func (wh *Whisper) add(envelope *Envelope) error { return fmt.Errorf("oversized Version") } - if len(envelope.AESNonce) > 12 { + if len(envelope.AESNonce) > AESNonceMaxLength { // the standard AES GSM nonce size is 12, // but const gcmStandardNonceSize cannot be accessed directly return fmt.Errorf("oversized AESNonce")