Skip to content

Commit

Permalink
fix(bazel): use own go-openssl repository with working BUILD files
Browse files Browse the repository at this point in the history
  • Loading branch information
nmeier authored and glouvigny committed Oct 14, 2019
1 parent 755d805 commit 7792f93
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
2 changes: 2 additions & 0 deletions go/go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions go/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/internal/crypto/crypto.go
Expand Up @@ -26,7 +26,7 @@ func (c *crypto) GetDevicePublicKey() sign.PubKey {
func (c *crypto) GetAccountPublicKey() (sign.PubKey, error) {
initialEntry := c.sigChain.GetInitialEntry()

if initialEntry.GetEntryType() != iface.SigChainEntryType_INIT_CHAIN {
if initialEntry.GetEntryType() != iface.SigChainEntryTypeInitChain {
return nil, errors.New("first sig chain node is invalid")
}

Expand Down
8 changes: 7 additions & 1 deletion go/internal/crypto/crypto_module.go
Expand Up @@ -25,6 +25,9 @@ func InitNewIdentity(ctx context.Context, store interface{}) (iface.Crypto, sign
}

sigChain, err := InitSigChain(privKey)
if err != nil {
return nil, nil, err
}

return NewCrypto(store, privKey, sigChain), privKey, nil
}
Expand Down Expand Up @@ -80,7 +83,10 @@ func GetRendezvousPointForTime(id, seed []byte, date time.Time) ([]byte, error)
mac := hmac.New(sha256.New, seed)
binary.BigEndian.PutUint64(buf, uint64(date.Unix()))

mac.Write(buf)
if _, err := mac.Write(buf); err != nil {
return nil, err
}

sum := mac.Sum(nil)

rendezvousPoint := sha256.Sum256(append(id, sum...))
Expand Down
10 changes: 5 additions & 5 deletions go/internal/cryptosigchain/crypto_sigchain.go
Expand Up @@ -40,9 +40,9 @@ func (m *SigChain) ListCurrentPubKeys() []crypto.PubKey {

for _, e := range m.Entries {
entryType := iface.SigChainEntryType(e.EntryTypeCode)
if entryType == iface.SigChainEntryType_UNDEFINED {
if entryType == iface.SigChainEntryTypeUndefined {
continue
} else if entryType == iface.SigChainEntryType_REVOKE_KEY {
} else if entryType == iface.SigChainEntryTypeRemoveKey {
delete(pubKeys, string(e.SubjectPublicKeyBytes))
} else {
pubKeys[string(e.SubjectPublicKeyBytes)] = e.SubjectPublicKeyBytes
Expand Down Expand Up @@ -72,7 +72,7 @@ func (m *SigChain) Init(privKey crypto.PrivKey) (iface.SigChainEntry, error) {
}

return m.appendEntry(privKey, &SigChainEntry{
EntryTypeCode: uint32(iface.SigChainEntryType_INIT_CHAIN),
EntryTypeCode: uint32(iface.SigChainEntryTypeInitChain),
SubjectPublicKeyBytes: subjectKeyBytes,
})
}
Expand All @@ -96,7 +96,7 @@ func (m *SigChain) AddEntry(privKey crypto.PrivKey, pubKey crypto.PubKey) (iface
}

return m.appendEntry(privKey, &SigChainEntry{
EntryTypeCode: uint32(iface.SigChainEntryType_ADD_KEY),
EntryTypeCode: uint32(iface.SigChainEntryTypeAddKey),
SubjectPublicKeyBytes: subjectKeyBytes,
})
}
Expand All @@ -120,7 +120,7 @@ func (m *SigChain) RemoveEntry(privKey crypto.PrivKey, pubKey crypto.PubKey) (if
}

return m.appendEntry(privKey, &SigChainEntry{
EntryTypeCode: uint32(iface.SigChainEntryType_REVOKE_KEY),
EntryTypeCode: uint32(iface.SigChainEntryTypeRemoveKey),
SubjectPublicKeyBytes: subjectKeyBytes,
})
}
Expand Down
8 changes: 4 additions & 4 deletions go/pkg/iface/crypto.go
Expand Up @@ -10,10 +10,10 @@ import (
type SigChainEntryType int8

const (
SigChainEntryType_UNDEFINED SigChainEntryType = 0
SigChainEntryType_INIT_CHAIN SigChainEntryType = 1
SigChainEntryType_ADD_KEY SigChainEntryType = 2
SigChainEntryType_REVOKE_KEY SigChainEntryType = 3
SigChainEntryTypeUndefined SigChainEntryType = 0
SigChainEntryTypeInitChain SigChainEntryType = 1
SigChainEntryTypeAddKey SigChainEntryType = 2
SigChainEntryTypeRemoveKey SigChainEntryType = 3
)

type SigChainEntry interface {
Expand Down

0 comments on commit 7792f93

Please sign in to comment.