SSHSecure/dh/const.go
2021-05-04 03:39:43 -04:00

41 lines
1.1 KiB
Go

package dh
const (
// QSizeMinimum Specifies the number of the most significant bit (0 to M).
// WARNING: internally, usually 1 to N.
QSizeMinimum = 511
// Prime sieving constants
// Assuming 8 bit bytes and 32 bit words.
ShiftBit = 3
ShiftByte = 2
ShiftWord = ShiftBit + ShiftByte
ShiftMegabyte = 20
ShiftMegaWord = ShiftMegabyte - ShiftBit
// Memory limits.
// LargeMinimum is 8 megabytes
LargeMinimum = uint32(8) // Originally an 8UL in moduli.c
// LargeMaximum is 127MB.
LargeMaximum = uint32(127)
// The largest sieve prime has to be < 2**32 on 32-bit systems.
SmallMaximum = uint32(0xffffffff) // 4294967295
// Can sieve all primes less than 2**32, as 65537**2 > 2**32-1.
TinyNumber = uint32(1) << 16
// Ensure enough bit space for testing 2*q.
TestMaximum = uint32(1) << 16
TestMinimum = QSizeMinimum + 1 // (uint32(1) << (ShiftWord - TestPower))
TestPower = 3 // 2**n, n < ShiftWord
)
var (
)
// Bit* functions operate on 32-bit words
func BitClear(a []uint32, n uint32) (i uint32) {
i = a[n >> ShiftWord] &= ~(uint32(1) << (n & 31))
return
}