コード例 #1
0
ファイル: key.go プロジェクト: andviro/go-cryptoapi
// Key extracts public key from container represented by context ctx, from
// key pair given by at parameter. It must be released after use by calling
// Close method.
func (ctx Ctx) Key(at KeyPairId) (res Key, err error) {
	if C.CryptGetUserKey(ctx.hProv, C.DWORD(at), &res.hKey) == 0 {
		err = getErr("Error getting key for container")
		return
	}
	return
}
コード例 #2
0
ファイル: key.go プロジェクト: Paher/go-cryptoapi
// Key extracts public key from container represented by context ctx, from
// key pair given by at parameter. It must be released after use by calling
// Close method.
func (ctx *Ctx) Key(at KeyPairId) (*Key, error) {
	var hk C.HCRYPTKEY

	if C.CryptGetUserKey(ctx.hProv, C.DWORD(at), &hk) == 0 {
		return nil, getErr("Error getting key for container")
	}
	return &Key{hKey: hk}, nil
}