container/ring.install:
container/vector.install:
crypto/aes.install: os.install strconv.install
-crypto/block.install: fmt.install io.install os.install strconv.install
+crypto/block.install: fmt.install hash.install io.install os.install strconv.install
crypto/hmac.install: crypto/md5.install crypto/sha1.install hash.install os.install
crypto/md5.install: hash.install os.install
crypto/rc4.install: os.install strconv.install
// and NIST Special Publication 800-38A.
package block
-import "io"
-
// A Cipher represents an implementation of block cipher
// using a given key. It provides the capability to encrypt
// or decrypt individual blocks. The mode implementations
Decrypt(src, dst []byte);
}
-// TODO(rsc): Digest belongs elsewhere.
-
-// A Digest is an implementation of a message digest algorithm.
-// Write data to it and then call Sum to retreive the digest.
-// Calling Reset resets the internal state, as though no data has
-// been written.
-type Digest interface {
- io.Writer;
- Sum() []byte;
- Reset();
-}
-
-
// Utility routines
func shift1(src, dst []byte) byte {
package block
-import "os"
+import (
+ "hash";
+ "os";
+)
const (
// minimal irreducible polynomial of degree b
// NewCMAC returns a new instance of a CMAC message authentication code
// digest using the given Cipher.
-func NewCMAC(c Cipher) Digest {
+func NewCMAC(c Cipher) hash.Hash {
var r byte;
n := c.BlockSize();
switch n {
d.c.Encrypt(d.digest, d.digest);
return d.digest;
}
+
+func (d *cmac) Size() int {
+ return len(d.digest);
+}
import (
"fmt";
+ "hash";
"io";
"os";
)
return fmt.Sprintf("crypto/block: EAX tag mismatch: read %x but computed %x", e.Read, e.Computed);
}
-func setupEAX(c Cipher, iv, hdr []byte, tagBytes int) (ctrIV, tag []byte, cmac Digest) {
+func setupEAX(c Cipher, iv, hdr []byte, tagBytes int) (ctrIV, tag []byte, cmac hash.Hash) {
n := len(iv);
if n != c.BlockSize() {
panicln("crypto/block: EAX: iv length", n, "!=", c.BlockSize());
return;
}
-func finishEAX(tag []byte, cmac Digest) {
+func finishEAX(tag []byte, cmac hash.Hash) {
// Finish CMAC #2 and xor into tag.
sum := cmac.Sum();
for i := range tag {
// Knows that cmac never returns write errors.
type cmacWriter struct {
w io.Writer;
- cmac Digest;
+ cmac hash.Hash;
}
func (cw *cmacWriter) Write(p []byte) (n int, err os.Error) {
// but the latter half is trivial.
type cmacReader struct {
r io.Reader;
- cmac Digest;
+ cmac hash.Hash;
tag []byte;
tmp []byte;
}