Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
5edbca2e
提交
5edbca2e
authored
10月 31, 2014
作者:
Jeromy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cleanup from CR
上级
09004e49
隐藏空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
29 行增加
和
32 行删除
+29
-32
Godeps.json
Godeps/Godeps.json
+2
-2
blockstore.go
blockstore/blockstore.go
+2
-6
key.go
crypto/key.go
+1
-1
rsa.go
crypto/rsa.go
+1
-1
handshake.go
crypto/spipe/handshake.go
+0
-1
spipe.pb.go
crypto/spipe/internal/pb/spipe.pb.go
+4
-4
spipe.proto
crypto/spipe/internal/pb/spipe.proto
+1
-1
signedpipe.go
crypto/spipe/signedpipe.go
+14
-12
spipe_test.go
crypto/spipe/spipe_test.go
+3
-3
dht.pb.go
routing/dht/pb/dht.pb.go
+1
-1
没有找到文件。
Godeps/Godeps.json
浏览文件 @
5edbca2e
{
{
"ImportPath"
:
"github.com/jbenet/go-ipfs"
,
"ImportPath"
:
"github.com/jbenet/go-ipfs"
,
"GoVersion"
:
"
go1.3.3
"
,
"GoVersion"
:
"
devel +9340f9f6dfc9 Fri Oct 31 00:48:57 2014 -0300
"
,
"Packages"
:
[
"Packages"
:
[
"./..."
"./..."
],
],
...
@@ -98,7 +98,7 @@
...
@@ -98,7 +98,7 @@
},
},
{
{
"ImportPath"
:
"github.com/jbenet/go-msgio"
,
"ImportPath"
:
"github.com/jbenet/go-msgio"
,
"Rev"
:
"
c9069ab79c95aa0686347b516972c7329c4391f2
"
"Rev"
:
"
ab0e7a0e111d7c7d814ad238bcbf3934efb76ac3
"
},
},
{
{
"ImportPath"
:
"github.com/jbenet/go-multiaddr"
,
"ImportPath"
:
"github.com/jbenet/go-multiaddr"
,
...
...
blockstore/blockstore.go
浏览文件 @
5edbca2e
...
@@ -36,12 +36,8 @@ func (bs *blockstore) Get(k u.Key) (*blocks.Block, error) {
...
@@ -36,12 +36,8 @@ func (bs *blockstore) Get(k u.Key) (*blocks.Block, error) {
if
!
ok
{
if
!
ok
{
return
nil
,
ValueTypeMismatch
return
nil
,
ValueTypeMismatch
}
}
//TODO: we *could* verify data coming in from the datastore here
// but its probably very unecessary
return
blocks
.
NewBlockWithHash
(
bdata
,
mh
.
Multihash
(
k
))
return
&
blocks
.
Block
{
Data
:
bdata
,
Multihash
:
mh
.
Multihash
(
k
),
},
nil
}
}
func
(
bs
*
blockstore
)
Put
(
block
*
blocks
.
Block
)
error
{
func
(
bs
*
blockstore
)
Put
(
block
*
blocks
.
Block
)
error
{
...
...
crypto/key.go
浏览文件 @
5edbca2e
...
@@ -51,7 +51,7 @@ type PrivKey interface {
...
@@ -51,7 +51,7 @@ type PrivKey interface {
// Generate a secret string of bytes
// Generate a secret string of bytes
GenSecret
()
[]
byte
GenSecret
()
[]
byte
Unen
crypt
(
b
[]
byte
)
([]
byte
,
error
)
De
crypt
(
b
[]
byte
)
([]
byte
,
error
)
}
}
type
PubKey
interface
{
type
PubKey
interface
{
...
...
crypto/rsa.go
浏览文件 @
5edbca2e
...
@@ -71,7 +71,7 @@ func (sk *RsaPrivateKey) GetPublic() PubKey {
...
@@ -71,7 +71,7 @@ func (sk *RsaPrivateKey) GetPublic() PubKey {
return
&
RsaPublicKey
{
&
sk
.
k
.
PublicKey
}
return
&
RsaPublicKey
{
&
sk
.
k
.
PublicKey
}
}
}
func
(
sk
*
RsaPrivateKey
)
Unen
crypt
(
b
[]
byte
)
([]
byte
,
error
)
{
func
(
sk
*
RsaPrivateKey
)
De
crypt
(
b
[]
byte
)
([]
byte
,
error
)
{
return
rsa
.
DecryptPKCS1v15
(
rand
.
Reader
,
sk
.
k
,
b
)
return
rsa
.
DecryptPKCS1v15
(
rand
.
Reader
,
sk
.
k
,
b
)
}
}
...
...
crypto/spipe/handshake.go
浏览文件 @
5edbca2e
...
@@ -276,7 +276,6 @@ func (s *SecurePipe) handleSecureIn(hashType, cipherType string, tIV, tCKey, tMK
...
@@ -276,7 +276,6 @@ func (s *SecurePipe) handleSecureIn(hashType, cipherType string, tIV, tCKey, tMK
hmacOk
:=
hmac
.
Equal
(
data
[
mark
:
],
expected
)
hmacOk
:=
hmac
.
Equal
(
data
[
mark
:
],
expected
)
if
!
hmacOk
{
if
!
hmacOk
{
s
.
Duplex
.
In
<-
nil
continue
continue
}
}
...
...
crypto/spipe/internal/pb/spipe.pb.go
浏览文件 @
5edbca2e
...
@@ -15,7 +15,7 @@ It has these top-level messages:
...
@@ -15,7 +15,7 @@ It has these top-level messages:
*/
*/
package
spipe_pb
package
spipe_pb
import
proto
"code.google.com/p/gogoprotobuf/proto"
import
proto
"
github.com/jbenet/go-ipfs/Godeps/_workspace/src/
code.google.com/p/gogoprotobuf/proto"
import
math
"math"
import
math
"math"
// Reference imports to suppress errors if they are not otherwise used.
// Reference imports to suppress errors if they are not otherwise used.
...
@@ -96,7 +96,7 @@ func (m *Exchange) GetSignature() []byte {
...
@@ -96,7 +96,7 @@ func (m *Exchange) GetSignature() []byte {
type
DataSig
struct
{
type
DataSig
struct
{
Data
[]
byte
`protobuf:"bytes,1,opt,name=data" json:"data,omitempty"`
Data
[]
byte
`protobuf:"bytes,1,opt,name=data" json:"data,omitempty"`
Sig
[]
byte
`protobuf:"bytes,2,opt,name=sig" json:"sig
,omitempty"`
Sig
nature
[]
byte
`protobuf:"bytes,2,opt,name=signature" json:"signature
,omitempty"`
Id
*
uint64
`protobuf:"varint,3,opt,name=id" json:"id,omitempty"`
Id
*
uint64
`protobuf:"varint,3,opt,name=id" json:"id,omitempty"`
XXX_unrecognized
[]
byte
`json:"-"`
XXX_unrecognized
[]
byte
`json:"-"`
}
}
...
@@ -112,9 +112,9 @@ func (m *DataSig) GetData() []byte {
...
@@ -112,9 +112,9 @@ func (m *DataSig) GetData() []byte {
return
nil
return
nil
}
}
func
(
m
*
DataSig
)
GetSig
()
[]
byte
{
func
(
m
*
DataSig
)
GetSig
nature
()
[]
byte
{
if
m
!=
nil
{
if
m
!=
nil
{
return
m
.
Sig
return
m
.
Sig
nature
}
}
return
nil
return
nil
}
}
...
...
crypto/spipe/internal/pb/spipe.proto
浏览文件 @
5edbca2e
...
@@ -15,6 +15,6 @@ message Exchange {
...
@@ -15,6 +15,6 @@ message Exchange {
message
DataSig
{
message
DataSig
{
optional
bytes
data
=
1
;
optional
bytes
data
=
1
;
optional
bytes
sig
=
2
;
optional
bytes
sig
nature
=
2
;
optional
uint64
id
=
3
;
optional
uint64
id
=
3
;
}
}
crypto/spipe/signedpipe.go
浏览文件 @
5edbca2e
...
@@ -25,8 +25,8 @@ type SignedPipe struct {
...
@@ -25,8 +25,8 @@ type SignedPipe struct {
ctx
context
.
Context
ctx
context
.
Context
cancel
context
.
CancelFunc
cancel
context
.
CancelFunc
mesid
uint64
localMsgID
uint64
theirmesid
uint64
removeMsgID
uint64
}
}
// secureChallengeSize is a constant that determines the initial challenge, and every subsequent
// secureChallengeSize is a constant that determines the initial challenge, and every subsequent
...
@@ -77,6 +77,8 @@ func (sp *SignedPipe) tryRecv() ([]byte, bool) {
...
@@ -77,6 +77,8 @@ func (sp *SignedPipe) tryRecv() ([]byte, bool) {
}
}
}
}
// reduceChallenge reduces a series of bytes into a
// single uint64 we can use as a seed for message IDs
func
reduceChallenge
(
cha
[]
byte
)
uint64
{
func
reduceChallenge
(
cha
[]
byte
)
uint64
{
var
out
uint64
var
out
uint64
for
_
,
b
:=
range
cha
{
for
_
,
b
:=
range
cha
{
...
@@ -134,8 +136,8 @@ func (sp *SignedPipe) handshake() error {
...
@@ -134,8 +136,8 @@ func (sp *SignedPipe) handshake() error {
return
context
.
Canceled
return
context
.
Canceled
}
}
//
Unen
crypt and verify their challenge
//
De
crypt and verify their challenge
unenc
,
err
:=
sp
.
local
.
PrivKey
()
.
Unen
crypt
(
theirEnc
)
unenc
,
err
:=
sp
.
local
.
PrivKey
()
.
De
crypt
(
theirEnc
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -182,8 +184,8 @@ func (sp *SignedPipe) handshake() error {
...
@@ -182,8 +184,8 @@ func (sp *SignedPipe) handshake() error {
return
errors
.
New
(
"Incorrect signature on challenge"
)
return
errors
.
New
(
"Incorrect signature on challenge"
)
}
}
sp
.
theirmesid
=
reduceChallenge
(
challenge
)
sp
.
removeMsgID
=
reduceChallenge
(
challenge
)
sp
.
mesid
=
reduceChallenge
(
unenc
)
sp
.
localMsgID
=
reduceChallenge
(
unenc
)
go
sp
.
handleIn
(
theirPubKey
)
go
sp
.
handleIn
(
theirPubKey
)
go
sp
.
handleOut
(
sp
.
local
.
PrivKey
())
go
sp
.
handleOut
(
sp
.
local
.
PrivKey
())
...
@@ -235,14 +237,14 @@ func (sp *SignedPipe) handleOut(pk ci.PrivKey) {
...
@@ -235,14 +237,14 @@ func (sp *SignedPipe) handleOut(pk ci.PrivKey) {
}
}
sdata
.
Data
=
data
sdata
.
Data
=
data
sdata
.
Sig
=
sig
sdata
.
Sig
nature
=
sig
sdata
.
Id
=
proto
.
Uint64
(
sp
.
mesid
)
sdata
.
Id
=
proto
.
Uint64
(
sp
.
localMsgID
)
b
,
err
:=
proto
.
Marshal
(
sdata
)
b
,
err
:=
proto
.
Marshal
(
sdata
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Error
(
"Error marshaling signed data object: %s"
,
err
)
log
.
Error
(
"Error marshaling signed data object: %s"
,
err
)
return
return
}
}
sp
.
mesid
++
sp
.
localMsgID
++
select
{
select
{
case
sp
.
insecure
.
Out
<-
b
:
case
sp
.
insecure
.
Out
<-
b
:
...
@@ -273,7 +275,7 @@ func (sp *SignedPipe) handleIn(theirPubkey ci.PubKey) {
...
@@ -273,7 +275,7 @@ func (sp *SignedPipe) handleIn(theirPubkey ci.PubKey) {
log
.
Error
(
"Failed to unmarshal sigdata object"
)
log
.
Error
(
"Failed to unmarshal sigdata object"
)
continue
continue
}
}
correct
,
err
:=
theirPubkey
.
Verify
(
sdata
.
GetData
(),
sdata
.
GetSig
())
correct
,
err
:=
theirPubkey
.
Verify
(
sdata
.
GetData
(),
sdata
.
GetSig
nature
())
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Error
(
err
)
log
.
Error
(
err
)
continue
continue
...
@@ -283,11 +285,11 @@ func (sp *SignedPipe) handleIn(theirPubkey ci.PubKey) {
...
@@ -283,11 +285,11 @@ func (sp *SignedPipe) handleIn(theirPubkey ci.PubKey) {
continue
continue
}
}
if
sdata
.
GetId
()
!=
sp
.
theirmesid
{
if
sdata
.
GetId
()
!=
sp
.
removeMsgID
{
log
.
Critical
(
"Out of order message id!"
)
log
.
Critical
(
"Out of order message id!"
)
return
return
}
}
sp
.
theirmesid
++
sp
.
removeMsgID
++
select
{
select
{
case
<-
sp
.
ctx
.
Done
()
:
case
<-
sp
.
ctx
.
Done
()
:
...
...
crypto/spipe/spipe_test.go
浏览文件 @
5edbca2e
...
@@ -118,7 +118,7 @@ func runEncryptBenchmark(b *testing.B) {
...
@@ -118,7 +118,7 @@ func runEncryptBenchmark(b *testing.B) {
}()
}()
data
:=
make
([]
byte
,
1024
*
512
)
data
:=
make
([]
byte
,
1024
*
512
)
util
.
New
Fast
Rand
()
.
Read
(
data
)
util
.
New
TimeSeeded
Rand
()
.
Read
(
data
)
// Begin actual benchmarking
// Begin actual benchmarking
b
.
ResetTimer
()
b
.
ResetTimer
()
...
@@ -170,7 +170,7 @@ func BenchmarkSignedChannel(b *testing.B) {
...
@@ -170,7 +170,7 @@ func BenchmarkSignedChannel(b *testing.B) {
}()
}()
data
:=
make
([]
byte
,
1024
*
512
)
data
:=
make
([]
byte
,
1024
*
512
)
util
.
New
Fast
Rand
()
.
Read
(
data
)
util
.
New
TimeSeeded
Rand
()
.
Read
(
data
)
// Begin actual benchmarking
// Begin actual benchmarking
b
.
ResetTimer
()
b
.
ResetTimer
()
...
@@ -199,7 +199,7 @@ func BenchmarkDataTransfer(b *testing.B) {
...
@@ -199,7 +199,7 @@ func BenchmarkDataTransfer(b *testing.B) {
}()
}()
data
:=
make
([]
byte
,
1024
*
512
)
data
:=
make
([]
byte
,
1024
*
512
)
util
.
New
Fast
Rand
()
.
Read
(
data
)
util
.
New
TimeSeeded
Rand
()
.
Read
(
data
)
// Begin actual benchmarking
// Begin actual benchmarking
b
.
ResetTimer
()
b
.
ResetTimer
()
...
...
routing/dht/pb/dht.pb.go
浏览文件 @
5edbca2e
...
@@ -13,7 +13,7 @@ It has these top-level messages:
...
@@ -13,7 +13,7 @@ It has these top-level messages:
*/
*/
package
dht_pb
package
dht_pb
import
proto
"code.google.com/p/gogoprotobuf/proto"
import
proto
"
github.com/jbenet/go-ipfs/Godeps/_workspace/src/
code.google.com/p/gogoprotobuf/proto"
import
math
"math"
import
math
"math"
// Reference imports to suppress errors if they are not otherwise used.
// Reference imports to suppress errors if they are not otherwise used.
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论