File: chacha_ref.go

package info (click to toggle)
golang-github-aead-chacha20 0.0~git20180709.8b13a72-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 184 kB
  • sloc: asm: 1,539; makefile: 2
file content (33 lines) | stat: -rw-r--r-- 901 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright (c) 2016 Andreas Auernhammer. All rights reserved.
// Use of this source code is governed by a license that can be
// found in the LICENSE file.

// +build !amd64,!386 gccgo appengine nacl

package chacha

import "encoding/binary"

func init() {
	useSSE2 = false
	useSSSE3 = false
	useAVX = false
	useAVX2 = false
}

func initialize(state *[64]byte, key []byte, nonce *[16]byte) {
	binary.LittleEndian.PutUint32(state[0:], sigma[0])
	binary.LittleEndian.PutUint32(state[4:], sigma[1])
	binary.LittleEndian.PutUint32(state[8:], sigma[2])
	binary.LittleEndian.PutUint32(state[12:], sigma[3])
	copy(state[16:], key[:])
	copy(state[48:], nonce[:])
}

func xorKeyStream(dst, src []byte, block, state *[64]byte, rounds int) int {
	return xorKeyStreamGeneric(dst, src, block, state, rounds)
}

func hChaCha20(out *[32]byte, nonce *[16]byte, key *[32]byte) {
	hChaCha20Generic(out, nonce, key)
}