Пример #1
0
// 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 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
}