// AcquireCtx acquires new CSP context from container name, provider name, // type and flags. Empty strings for container and provider // names are typically used for CryptVerifyContext flag setting. Created context // must be eventually released with its Close method. func AcquireCtx(container, provider string, provType ProvType, flags CryptFlag) (*Ctx, error) { var hprov C.HCRYPTPROV cContainer := charPtr(container) cProvider := charPtr(provider) defer freePtr(cContainer) defer freePtr(cProvider) if C.CryptAcquireContext(&hprov, cContainer, cProvider, C.DWORD(provType), C.DWORD(flags)) == 0 { return nil, getErr("Error acquiring context") } return &Ctx{hProv: hprov}, nil }
// AcquireCtx acquires new CSP context from container name, provider name, // type and flags. Empty strings for container and provider // names are typically used for CryptVerifyContext flag setting. Created context // must be eventually released with its Close method. func AcquireCtx(container, provider string, provType ProvType, flags CryptFlag) (res Ctx, err error) { cContainer := charPtr(container) defer freePtr(cContainer) cProvider := charPtr(provider) defer freePtr(cProvider) if C.CryptAcquireContext(&res.hProv, cContainer, cProvider, C.DWORD(provType), C.DWORD(flags)) == 0 { err = getErr("Error acquiring context") return } return }