Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
7bbc0084
提交
7bbc0084
authored
12月 24, 2014
作者:
Juan Batiz-Benet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
updated go.crypto/sha3
上级
4807127d
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
215 行增加
和
4 行删除
+215
-4
Godeps.json
Godeps/Godeps.json
+4
-4
doc.go
...ps/_workspace/src/code.google.com/p/go.crypto/sha3/doc.go
+68
-0
hashes.go
..._workspace/src/code.google.com/p/go.crypto/sha3/hashes.go
+65
-0
keccakKats.json.deflate
.../code.google.com/p/go.crypto/sha3/keccakKats.json.deflate
+0
-0
keccakf.go
...workspace/src/code.google.com/p/go.crypto/sha3/keccakf.go
+0
-0
register.go
...orkspace/src/code.google.com/p/go.crypto/sha3/register.go
+18
-0
sha3.go
...s/_workspace/src/code.google.com/p/go.crypto/sha3/sha3.go
+0
-0
sha3_test.go
...rkspace/src/code.google.com/p/go.crypto/sha3/sha3_test.go
+0
-0
shake.go
.../_workspace/src/code.google.com/p/go.crypto/sha3/shake.go
+60
-0
没有找到文件。
Godeps/Godeps.json
浏览文件 @
7bbc0084
...
...
@@ -21,13 +21,13 @@
},
{
"ImportPath"
:
"code.google.com/p/go.crypto/blowfish"
,
"Comment"
:
"null-2
19
"
,
"Rev"
:
"
00a7d3b31bbab5795b4a51933c04fc2768242970
"
"Comment"
:
"null-2
36
"
,
"Rev"
:
"
69e2a90ed92d03812364aeb947b7068dc42e561e
"
},
{
"ImportPath"
:
"code.google.com/p/go.crypto/sha3"
,
"Comment"
:
"null-2
19
"
,
"Rev"
:
"
00a7d3b31bbab5795b4a51933c04fc2768242970
"
"Comment"
:
"null-2
36
"
,
"Rev"
:
"
69e2a90ed92d03812364aeb947b7068dc42e561e
"
},
{
"ImportPath"
:
"code.google.com/p/go.net/context"
,
...
...
Godeps/_workspace/src/code.google.com/p/go.crypto/sha3/doc.go
0 → 100644
浏览文件 @
7bbc0084
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package sha3 implements the SHA-3 fixed-output-length hash functions and
// the SHAKE variable-output-length hash functions defined by FIPS-202.
//
// Both types of hash function use the "sponge" construction and the Keccak
// permutation. For a detailed specification see http://keccak.noekeon.org/
//
//
// Guidance
//
// If you aren't sure what function you need, use SHAKE256 with at least 64
// bytes of output.
//
// If you need a secret-key MAC (message authentication code), prepend the
// secret key to the input, hash with SHAKE256 and read at least 32 bytes of
// output.
//
//
// Security strengths
//
// The SHA3-x functions have a security strength against preimage attacks of x
// bits. Since they only produce x bits of output, their collision-resistance
// is only x/2 bits.
//
// The SHAKE-x functions have a generic security strength of x bits against
// all attacks, provided that at least 2x bits of their output is used.
// Requesting more than 2x bits of output does not increase the collision-
// resistance of the SHAKE functions.
//
//
// The sponge construction
//
// A sponge builds a pseudo-random function from a pseudo-random permutation,
// by applying the permutation to a state of "rate + capacity" bytes, but
// hiding "capacity" of the bytes.
//
// A sponge starts out with a zero state. To hash an input using a sponge, up
// to "rate" bytes of the input are XORed into the sponge's state. The sponge
// has thus been "filled up" and the permutation is applied. This process is
// repeated until all the input has been "absorbed". The input is then padded.
// The digest is "squeezed" from the sponge by the same method, except that
// output is copied out.
//
// A sponge is parameterized by its generic security strength, which is equal
// to half its capacity; capacity + rate is equal to the permutation's width.
//
// Since the KeccakF-1600 permutation is 1600 bits (200 bytes) wide, this means
// that security_strength == (1600 - bitrate) / 2.
//
//
// Recommendations, detailed
//
// The SHAKE functions are recommended for most new uses. They can produce
// output of arbitrary length. SHAKE256, with an output length of at least
// 64 bytes, provides 256-bit security against all attacks.
//
// The Keccak team recommends SHAKE256 for most applications upgrading from
// SHA2-512. (NIST chose a much stronger, but much slower, sponge instance
// for SHA3-512.)
//
// The SHA-3 functions are "drop-in" replacements for the SHA-2 functions.
// They produce output of the same length, with the same security strengths
// against all attacks. This means, in particular, that SHA3-256 only has
// 128-bit collision resistance, because its output length is 32 bytes.
package
sha3
Godeps/_workspace/src/code.google.com/p/go.crypto/sha3/hashes.go
0 → 100644
浏览文件 @
7bbc0084
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
sha3
// This file provides functions for creating instances of the SHA-3
// and SHAKE hash functions, as well as utility functions for hashing
// bytes.
import
(
"hash"
)
// New224 creates a new SHA3-224 hash.
// Its generic security strength is 224 bits against preimage attacks,
// and 112 bits against collision attacks.
func
New224
()
hash
.
Hash
{
return
&
state
{
rate
:
144
,
outputLen
:
28
,
dsbyte
:
0x06
}
}
// New256 creates a new SHA3-256 hash.
// Its generic security strength is 256 bits against preimage attacks,
// and 128 bits against collision attacks.
func
New256
()
hash
.
Hash
{
return
&
state
{
rate
:
136
,
outputLen
:
32
,
dsbyte
:
0x06
}
}
// New384 creates a new SHA3-384 hash.
// Its generic security strength is 384 bits against preimage attacks,
// and 192 bits against collision attacks.
func
New384
()
hash
.
Hash
{
return
&
state
{
rate
:
104
,
outputLen
:
48
,
dsbyte
:
0x06
}
}
// New512 creates a new SHA3-512 hash.
// Its generic security strength is 512 bits against preimage attacks,
// and 256 bits against collision attacks.
func
New512
()
hash
.
Hash
{
return
&
state
{
rate
:
72
,
outputLen
:
64
,
dsbyte
:
0x06
}
}
// Sum224 returns the SHA3-224 digest of the data.
func
Sum224
(
data
[]
byte
)
(
digest
[
28
]
byte
)
{
h
:=
New224
()
h
.
Write
(
data
)
h
.
Sum
(
digest
[
:
0
])
return
}
// Sum256 returns the SHA3-256 digest of the data.
func
Sum256
(
data
[]
byte
)
(
digest
[
32
]
byte
)
{
h
:=
New256
()
h
.
Write
(
data
)
h
.
Sum
(
digest
[
:
0
])
return
}
// Sum384 returns the SHA3-384 digest of the data.
func
Sum384
(
data
[]
byte
)
(
digest
[
48
]
byte
)
{
h
:=
New384
()
h
.
Write
(
data
)
h
.
Sum
(
digest
[
:
0
])
return
}
// Sum512 returns the SHA3-512 digest of the data.
func
Sum512
(
data
[]
byte
)
(
digest
[
64
]
byte
)
{
h
:=
New512
()
h
.
Write
(
data
)
h
.
Sum
(
digest
[
:
0
])
return
}
Godeps/_workspace/src/code.google.com/p/go.crypto/sha3/keccakKats.json.deflate
0 → 100644
浏览文件 @
7bbc0084
File added
Godeps/_workspace/src/code.google.com/p/go.crypto/sha3/keccakf.go
浏览文件 @
7bbc0084
差异被折叠。
点击展开。
Godeps/_workspace/src/code.google.com/p/go.crypto/sha3/register.go
0 → 100644
浏览文件 @
7bbc0084
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build go1.4
package
sha3
import
(
"crypto"
)
func
init
()
{
crypto
.
RegisterHash
(
crypto
.
SHA3_224
,
New224
)
crypto
.
RegisterHash
(
crypto
.
SHA3_256
,
New256
)
crypto
.
RegisterHash
(
crypto
.
SHA3_384
,
New384
)
crypto
.
RegisterHash
(
crypto
.
SHA3_512
,
New512
)
}
Godeps/_workspace/src/code.google.com/p/go.crypto/sha3/sha3.go
浏览文件 @
7bbc0084
差异被折叠。
点击展开。
Godeps/_workspace/src/code.google.com/p/go.crypto/sha3/sha3_test.go
浏览文件 @
7bbc0084
差异被折叠。
点击展开。
Godeps/_workspace/src/code.google.com/p/go.crypto/sha3/shake.go
0 → 100644
浏览文件 @
7bbc0084
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
sha3
// This file defines the ShakeHash interface, and provides
// functions for creating SHAKE instances, as well as utility
// functions for hashing bytes to arbitrary-length output.
import
(
"io"
)
// ShakeHash defines the interface to hash functions that
// support arbitrary-length output.
type
ShakeHash
interface
{
// Write absorbs more data into the hash's state. It panics if input is
// written to it after output has been read from it.
io
.
Writer
// Read reads more output from the hash; reading affects the hash's
// state. (ShakeHash.Read is thus very different from Hash.Sum)
// It never returns an error.
io
.
Reader
// Clone returns a copy of the ShakeHash in its current state.
Clone
()
ShakeHash
// Reset resets the ShakeHash to its initial state.
Reset
()
}
func
(
d
*
state
)
Clone
()
ShakeHash
{
return
d
.
clone
()
}
// NewShake128 creates a new SHAKE128 variable-output-length ShakeHash.
// Its generic security strength is 128 bits against all attacks if at
// least 32 bytes of its output are used.
func
NewShake128
()
ShakeHash
{
return
&
state
{
rate
:
168
,
dsbyte
:
0x1f
}
}
// NewShake256 creates a new SHAKE128 variable-output-length ShakeHash.
// Its generic security strength is 256 bits against all attacks if
// at least 64 bytes of its output are used.
func
NewShake256
()
ShakeHash
{
return
&
state
{
rate
:
136
,
dsbyte
:
0x1f
}
}
// ShakeSum128 writes an arbitrary-length digest of data into hash.
func
ShakeSum128
(
hash
,
data
[]
byte
)
{
h
:=
NewShake128
()
h
.
Write
(
data
)
h
.
Read
(
hash
)
}
// ShakeSum256 writes an arbitrary-length digest of data into hash.
func
ShakeSum256
(
hash
,
data
[]
byte
)
{
h
:=
NewShake256
()
h
.
Write
(
data
)
h
.
Read
(
hash
)
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论