代码拉取完成,页面将自动刷新
/*
* Copyright (c) 2000-2018, 达梦数据库有限公司.
* All rights reserved.
*/
package security
import "math/big"
type DhKey struct {
x *big.Int
y *big.Int
group *dhGroup
}
func newPublicKey(s []byte) *DhKey {
key := new(DhKey)
key.y = new(big.Int).SetBytes(s)
return key
}
func (dk *DhKey) GetX() *big.Int {
x := new(big.Int)
x.Set(dk.x)
return x
}
func (dk *DhKey) GetY() *big.Int {
y := new(big.Int)
y.Set(dk.y)
return y
}
func (dk *DhKey) GetYBytes() []byte {
if dk.y == nil {
return nil
}
if dk.group != nil {
blen := (dk.group.p.BitLen() + 7) / 8
ret := make([]byte, blen)
copyWithLeftPad(ret, dk.y.Bytes())
return ret
}
return dk.y.Bytes()
}
func (dk *DhKey) GetYString() string {
if dk.y == nil {
return ""
}
return dk.y.String()
}
func (dk *DhKey) IsPrivateKey() bool {
return dk.x != nil
}
func copyWithLeftPad(dest, src []byte) {
numPaddingBytes := len(dest) - len(src)
for i := 0; i < numPaddingBytes; i++ {
dest[i] = 0
}
copy(dest[:numPaddingBytes], src)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。