Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
b7ef541f
Commit
b7ef541f
authored
Oct 14, 2009
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
toss crypto/block Digest in favor of hash.Hash
R=r DELTA=30 (8 added, 15 deleted, 7 changed) OCL=35677 CL=35713
parent
f6d67c9e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
22 deletions
+15
-22
src/pkg/Make.deps
src/pkg/Make.deps
+1
-1
src/pkg/crypto/block/cipher.go
src/pkg/crypto/block/cipher.go
+0
-15
src/pkg/crypto/block/cmac.go
src/pkg/crypto/block/cmac.go
+9
-2
src/pkg/crypto/block/eax.go
src/pkg/crypto/block/eax.go
+5
-4
No files found.
src/pkg/Make.deps
View file @
b7ef541f
...
...
@@ -13,7 +13,7 @@ container/list.install:
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
...
...
src/pkg/crypto/block/cipher.go
View file @
b7ef541f
...
...
@@ -8,8 +8,6 @@
// 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
...
...
@@ -27,19 +25,6 @@ type Cipher interface {
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
{
...
...
src/pkg/crypto/block/cmac.go
View file @
b7ef541f
...
...
@@ -7,7 +7,10 @@
package
block
import
"os"
import
(
"hash"
;
"os"
;
)
const
(
// minimal irreducible polynomial of degree b
...
...
@@ -25,7 +28,7 @@ type cmac struct {
// 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
{
...
...
@@ -98,3 +101,7 @@ func (d *cmac) Sum() []byte {
d
.
c
.
Encrypt
(
d
.
digest
,
d
.
digest
);
return
d
.
digest
;
}
func
(
d
*
cmac
)
Size
()
int
{
return
len
(
d
.
digest
);
}
src/pkg/crypto/block/eax.go
View file @
b7ef541f
...
...
@@ -16,6 +16,7 @@ package block
import
(
"fmt"
;
"hash"
;
"io"
;
"os"
;
)
...
...
@@ -32,7 +33,7 @@ func (e *EAXTagError) String() string {
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
());
...
...
@@ -63,7 +64,7 @@ func setupEAX(c Cipher, iv, hdr []byte, tagBytes int) (ctrIV, tag []byte, cmac D
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
{
...
...
@@ -75,7 +76,7 @@ func finishEAX(tag []byte, cmac Digest) {
// 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
)
{
...
...
@@ -133,7 +134,7 @@ func (x *eaxEncrypter) Close() os.Error {
// but the latter half is trivial.
type
cmacReader
struct
{
r
io
.
Reader
;
cmac
Digest
;
cmac
hash
.
Hash
;
tag
[]
byte
;
tmp
[]
byte
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment