dh

package
v0.0.0-...-7f98e7a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 4, 2021 License: GPL-3.0 Imports: 8 Imported by: 0

README

THIS SUBMODULE IS INCOMPLETE. DO NOT USE IT.
It technically is not necessary as upstream offers generated parameters.
Theoretically as long as we filter anything 2048 bits and lower, it should be fine.

The functions, etc. (even a significant amount of the comments) found in this
sub-component are ported almost directly from the openssh-portable[0]'s
`moduli.c`[1] code (with, of course, changes made where appropriate to match
and take advantage of Golang and its patterns).

The OpenBSD and OpenSSH(-portable) teams have my gratitude.

OpenSSH/OpenSSH portable are released under a combination of the following licenses[2]:

* public domain
* "BSD-style"
* 2-, 3-, and 4-clause BSD
* Beerware

The license in full for OpenSSH/OpenSSH-Portable can be found at [2].

The license for OpenSSH-Portable's `moduli.c` is as follows:

###########################################################################
Copyright 1994 Phil Karn <karn@qualcomm.com>
Copyright 1996-1998, 2003 William Allen Simpson <wsimpson@greendragon.com>
Copyright 2000 Niels Provos <provos@citi.umich.edu>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
###########################################################################


[0] https://www.openssh.com/portable.html
    https://anongit.mindrot.org/openssh.git

[1] https://anongit.mindrot.org/openssh.git/tree/moduli.c

[2] https://anongit.mindrot.org/openssh.git/tree/LICENCE

Documentation

Index

Constants

View Source
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
	// Minimum number of primality tests to perform
	TrialMinimum = 4
)

Variables

This section is empty.

Functions

func BitClear

func BitClear(a []uint32, n uint32) (i uint32)

Bit* functions operate on 32-bit words

func BitSet

func BitSet(a []uint32, n uint32) (i uint32)

func BitTest

func BitTest(a []uint32, n uint32) (i uint32)

func Generate

func Generate() (moduliEntries []moduli.Entry, err error)

Generate builds a slice of moduli.Entry entries. TODO: DO THIS NATIVELY. Idealy with goroutines and a channel? buffer? for the primes and sieving.

Types

type LargeSieve

type LargeSieve *uint32

sieve relative to the initial value

type SmallSieve

type SmallSieve *uint32

sieve 2**30 in 2**16 parts

type TinySieve

type TinySieve *uint32

sieve 2**16

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL