本文整理汇总了Golang中github.com/dedis/crypto/abstract.Suite.String方法的典型用法代码示例。如果您正苦于以下问题:Golang Suite.String方法的具体用法?Golang Suite.String怎么用?Golang Suite.String使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/dedis/crypto/abstract.Suite
的用法示例。
在下文中一共展示了Suite.String方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: init
// Determine all the alternative DH point positions for a ciphersuite.
func (si *suiteInfo) init(ste abstract.Suite, nlevels int) {
si.ste = ste
si.tag = make([]uint32, nlevels)
si.pos = make([]int, nlevels)
si.plen = ste.Point().(abstract.Hiding).HideLen() // XXX
// Create a pseudo-random stream from which to pick positions
str := fmt.Sprintf("NegoCipherSuite:%s", ste.String())
rand := ste.Cipher([]byte(str))
// Alternative 0 is always at position 0, so start with level 1.
levofs := 0 // starting offset for current level
//fmt.Printf("Suite %s positions:\n", ste.String())
for i := 0; i < nlevels; i++ {
// Pick a random position within this level
var buf [4]byte
rand.XORKeyStream(buf[:], buf[:])
levlen := 1 << uint(i) // # alt positions at this level
levmask := levlen - 1 // alternative index mask
si.tag[i] = binary.BigEndian.Uint32(buf[:])
levidx := int(si.tag[i]) & levmask
si.pos[i] = levofs + levidx*si.plen
//fmt.Printf("%d: idx %d/%d pos %d\n",
// i, levidx, levlen, si.pos[i])
levofs += levlen * si.plen // next level table offset
}
// Limit of highest point field
si.max = si.pos[nlevels-1] + si.plen
}
示例2: GenKey
// Generate a new public/private keypair with the given ciphersuite
// and Save it to the application's previously-loaded configuration.
func (f *File) GenKey(keys *Keys, suite abstract.Suite) (KeyPair, error) {
// Create the map if it doesn't exist
// if *keys == nil {
// *keys = make(map[string] KeyInfo)
// }
// Create a fresh public/private keypair
p := KeyPair{}
p.Gen(suite, random.Stream)
pubId := p.PubId()
// Write the private key file
secname := f.dirName + "/sec-" + pubId
r := util.Replacer{}
if err := r.Open(secname); err != nil {
return KeyPair{}, err
}
defer r.Abort()
// Write the secret key
if err := suite.Write(r.File, &p.Secret); err != nil {
return KeyPair{}, err
}
// Commit the secret key
if err := r.Commit(); err != nil {
return KeyPair{}, err
}
// Re-write the config file with the new public key
*keys = append(*keys, KeyInfo{suite.String(), pubId})
if err := f.Save(); err != nil {
return KeyPair{}, err
}
return p, nil
}
示例3: add
func (s Suites) add(suite abstract.Suite) {
s[suite.String()] = suite
}
示例4: namePriv
package main
import (
"os"
"github.com/codegangsta/cli"
"github.com/dedis/cothority/lib/cliutils"
"github.com/dedis/cothority/lib/conode"
"github.com/dedis/cothority/lib/dbg"
"github.com/dedis/crypto/abstract"
"github.com/dedis/crypto/edwards/ed25519"
)
// Which suite to use
var suite abstract.Suite = ed25519.NewAES128SHA256Ed25519(false)
var suiteStr string = suite.String()
// where to write the key file .priv + .pub
var defaultKeyFile string = "key"
// Returns the name of the file for the private key
func namePriv(key string) string {
return key + ".priv"
}
// Returns the name of the file for the public key
func namePub(key string) string {
return key + ".pub"
}
// config file by default