1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // The block package is deprecated, use cipher instead.
6 // The block package implements standard block cipher modes
7 // that can be wrapped around low-level block cipher implementations.
8 // See http://csrc.nist.gov/groups/ST/toolkit/BCM/current_modes.html
9 // and NIST Special Publication 800-38A.
12 // A Cipher represents an implementation of block cipher
13 // using a given key. It provides the capability to encrypt
14 // or decrypt individual blocks. The mode implementations
15 // extend that capability to streams of blocks.
16 type Cipher interface {
17 // BlockSize returns the cipher's block size.
20 // Encrypt encrypts the first block in src into dst.
21 // Src and dst may point at the same memory.
22 Encrypt(dst, src []byte)
24 // Decrypt decrypts the first block in src into dst.
25 // Src and dst may point at the same memory.
26 Decrypt(dst, src []byte)
31 func shift1(dst, src []byte) byte {
33 for i := len(src) - 1; i >= 0; i-- {
35 dst[i] = src[i]<<1 | b
41 func same(p, q []byte) bool {
45 for i := 0; i < len(p); i++ {
53 func dup(p []byte) []byte {
54 q := make([]byte, len(p))