Imports #
"internal/byteorder"
"sync"
"crypto/cipher"
"crypto/internal/fips140/alias"
"crypto/internal/fips140only"
"errors"
"internal/byteorder"
"strconv"
"internal/byteorder"
"sync"
"crypto/cipher"
"crypto/internal/fips140/alias"
"crypto/internal/fips140only"
"errors"
"internal/byteorder"
"strconv"
The DES block size in bytes.
const BlockSize = 8
Used to expand an input block of 32 bits, producing an output block of 48 bits.
var expansionFunction = [48]byte{...}
feistelBox[s][16*i+j] contains the output of permutationFunction for sBoxes[s][i][j] << 4*(7-s)
var feistelBox [8][64]uint32
var feistelBoxOnce sync.Once
Used to perform a final permutation of a 4-bit preoutput block. This is the inverse of initialPermutation
var finalPermutation = [64]byte{...}
Used to perform an initial permutation of a 64-bit input block.
var initialPermutation = [64]byte{...}
Size of left rotation per round in each half of the key schedule
var ksRotations = [16]uint8{...}
Yields a 32-bit output from a 32-bit input
var permutationFunction = [32]byte{...}
Used in the key schedule to select 56 bits from a 64-bit input.
var permutedChoice1 = [56]byte{...}
Used in the key schedule to produce each subkey by selecting 48 bits from the 56-bit input
var permutedChoice2 = [48]byte{...}
8 S-boxes composed of 4 rows and 16 columns Used in the DES cipher function
var sBoxes = [8][4][16]uint8{...}
type KeySizeError int
desCipher is an instance of DES encryption.
type desCipher struct {
subkeys [16]uint64
}
A tripleDESCipher is an instance of TripleDES encryption.
type tripleDESCipher struct {
cipher1 desCipher
cipher2 desCipher
cipher3 desCipher
}
func (c *tripleDESCipher) BlockSize() int
func (c *desCipher) BlockSize() int
func (c *tripleDESCipher) Decrypt(dst []byte, src []byte)
func (c *desCipher) Decrypt(dst []byte, src []byte)
func (c *desCipher) Encrypt(dst []byte, src []byte)
func (c *tripleDESCipher) Encrypt(dst []byte, src []byte)
func (k KeySizeError) Error() string
NewCipher creates and returns a new [cipher.Block].
func NewCipher(key []byte) (cipher.Block, error)
NewTripleDESCipher creates and returns a new [cipher.Block].
func NewTripleDESCipher(key []byte) (cipher.Block, error)
func cryptBlock(subkeys []uint64, dst []byte, src []byte, decrypt bool)
DES Feistel function. feistelBox must be initialized via feistelBoxOnce.Do(initFeistelBox) first.
func feistel(l uint32, r uint32, k0 uint64, k1 uint64) (lout uint32, rout uint32)
creates 16 56-bit subkeys from the original key.
func (c *desCipher) generateSubkeys(keyBytes []byte)
func initFeistelBox()
creates 16 28-bit blocks rotated according to the rotation schedule.
func ksRotate(in uint32) (out []uint32)
general purpose function to perform DES block permutations.
func permuteBlock(src uint64, permutation []uint8) (block uint64)
permuteFinalBlock is equivalent to the permutation defined by finalPermutation.
func permuteFinalBlock(block uint64) uint64
permuteInitialBlock is equivalent to the permutation defined by initialPermutation.
func permuteInitialBlock(block uint64) uint64
Expand 48-bit input to 64-bit, with each 6-bit block padded by extra two bits at the top. By doing so, we can have the input blocks (four bits each), and the key blocks (six bits each) well-aligned without extra shifts/rotations for alignments.
func unpack(x uint64) uint64
Generated with Arrow