本文整理匯總了Golang中crypto/dsa.PrivateKey類的典型用法代碼示例。如果您正苦於以下問題:Golang PrivateKey類的具體用法?Golang PrivateKey怎麽用?Golang PrivateKey使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了PrivateKey類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: generateDSA
// generate a dsa keypair
func generateDSA(priv *dsa.PrivateKey, rand io.Reader) error {
// put our paramters in
priv.P = param.P
priv.Q = param.Q
priv.G = param.G
// generate the keypair
return dsa.GenerateKey(priv, rand)
}
示例2: readPrivateKeyDSA
func readPrivateKeyDSA(m map[string]string) (PrivateKey, error) {
p := new(dsa.PrivateKey)
p.X = big.NewInt(0)
for k, v := range m {
switch k {
case "private_value(x)":
v1, err := fromBase64([]byte(v))
if err != nil {
return nil, err
}
p.X.SetBytes(v1)
case "created", "publish", "activate":
/* not used in Go (yet) */
}
}
return p, nil
}
示例3: assignParameter
func assignParameter(k *dsa.PrivateKey, s string, v *big.Int) bool {
switch s {
case "g":
k.G = v
case "p":
k.P = v
case "q":
k.Q = v
case "x":
k.X = v
case "y":
k.Y = v
default:
return false
}
return true
}
示例4: parseDSAPrivateKey
func (pk *PrivateKey) parseDSAPrivateKey(data []byte) (err os.Error) {
dsaPub := pk.PublicKey.PublicKey.(*dsa.PublicKey)
dsaPriv := new(dsa.PrivateKey)
dsaPriv.PublicKey = *dsaPub
buf := bytes.NewBuffer(data)
x, _, err := readMPI(buf)
if err != nil {
return
}
dsaPriv.X = new(big.Int).SetBytes(x)
pk.PrivateKey = dsaPriv
pk.Encrypted = false
pk.encryptedData = nil
return nil
}