예제 #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
}