Exemple #1
0
        /// Creates a new Secp256k1 context with the specified capabilities
        public static Secp256K1 WithCaps(ContextFlag caps)
        {
            var flag = Secp256K1Options.Secp256K1StartNone;

            switch (caps)
            {
            case ContextFlag.None:
                flag = Secp256K1Options.Secp256K1StartNone;

                break;

            case ContextFlag.SignOnly:
                flag = Secp256K1Options.Secp256K1StartSign;
                break;

            case ContextFlag.VerifyOnly:
                flag = Secp256K1Options.Secp256K1StartVerify;
                break;

            case ContextFlag.Full:
            case ContextFlag.Commit:
                flag = Secp256K1Options.Secp256K1StartSign | Secp256K1Options.Secp256K1StartVerify;
                break;
            }

            var ctx = Proxy.secp256k1_context_create((uint)flag);

            return(new Secp256K1(ctx, caps));
        }
 internal static extern SecStatus AcceptSecurityContext_1(
     ref SECURITY_HANDLE phCredential,
     ref SECURITY_HANDLE phContext,
     ref SecBufferDesc pInput,
     ContextFlag fContextReq,
     uint TargetDataRep,
     ref SECURITY_HANDLE phNewContext,
     out SecBufferDesc pOutput,
     out ContextFlag pfContextAttr,
     out SECURITY_INTEGER ptsTimeStamp
     );
Exemple #3
0
        /// <summary>
        /// MissingMethodException. call AcquireContext instead
        /// </summary>
        public static IntPtr CpAcquireContext(string container, ContextFlag flag)
        {
            IntPtr        prov;
            StringBuilder sb = new StringBuilder(container);

            byte[]  vTable = new byte[0];            //VTableProvStruc with callbacks
            bool    retVal = Crypto.CPAcquireContext(out prov, sb, (uint)flag, vTable);
            ErrCode ec     = Error.HandleRetVal(retVal);

            return(prov);
        }
Exemple #4
0
        public SspiSecurityContext(
            Credential credential,
            string package,
            ContextFlag clientFlags = DefaultRequiredFlags,
            ContextFlag serverFlags = DefaultServerRequiredFlags
            )
        {
            this.credential  = credential;
            this.clientFlags = clientFlags;
            this.serverFlags = serverFlags;

            Package = package;
        }
 internal static extern SecStatus InitializeSecurityContext_1(
     ref SECURITY_HANDLE phCredential,
     ref SECURITY_HANDLE phContext,
     string pszTargetName,
     ContextFlag fContextReq,
     int Reserved1,
     int TargetDataRep,
     ref SecBufferDesc pInput,
     int Reserved2,
     ref SECURITY_HANDLE phNewContext,
     ref SecBufferDesc pOutput,
     out ContextFlag pfContextAttr,
     ref IntPtr ptsExpiry
     );
Exemple #6
0
 /// <summary>
 /// MissingMethodException. call AcquireContext instead
 /// </summary>
 public static IntPtr CpAcquireContext(string container, ContextFlag flag)
 {
     IntPtr prov;
     StringBuilder sb = new StringBuilder(container);
     byte[] vTable = new byte[0]; //VTableProvStruc with callbacks
     bool retVal = Crypto.CPAcquireContext(out prov, sb, (uint) flag, vTable);
     ErrCode ec = Error.HandleRetVal(retVal);
     return prov;
 }
Exemple #7
0
 public static IntPtr AcquireContext(string conName, string provName, ProvType provType, ContextFlag conFlag)
 {
     IntPtr hProv;
     bool retVal = Crypto.CryptAcquireContext(out hProv, conName, provName, (uint) provType, (uint) conFlag);
     ErrCode ec = Error.HandleRetVal(retVal, ErrCode.NTE_BAD_KEYSET);
     if(ec == ErrCode.NTE_BAD_KEYSET) //try creating a new key container
     {
         retVal = Crypto.CryptAcquireContext(out hProv, conName, provName, (uint) provType, (uint) ContextFlag.NEWKEYSET);
         ec = Error.HandleRetVal(retVal);
     }
     if(hProv == IntPtr.Zero)
         throw new Exception("bNb.Sec: " + ec.ToString());
     return hProv;
 }
Exemple #8
0
 public static IntPtr AcquireContext(string provName, ProvType provType, ContextFlag conFlag)
 {
     return AcquireContext(null, provName, provType, conFlag);
 }
Exemple #9
0
 private Secp256K1(IntPtr ctx, ContextFlag caps)
 {
     Ctx  = ctx;
     Caps = caps;
 }
Exemple #10
0
        public static IntPtr AcquireContext(string conName, string provName, ProvType provType, ContextFlag conFlag)
        {
            IntPtr  hProv;
            bool    retVal = Crypto.CryptAcquireContext(out hProv, conName, provName, (uint)provType, (uint)conFlag);
            ErrCode ec     = Error.HandleRetVal(retVal, ErrCode.NTE_BAD_KEYSET);

            if (ec == ErrCode.NTE_BAD_KEYSET)            //try creating a new key container
            {
                retVal = Crypto.CryptAcquireContext(out hProv, conName, provName, (uint)provType, (uint)ContextFlag.NEWKEYSET);
                ec     = Error.HandleRetVal(retVal);
            }
            if (hProv == IntPtr.Zero)
            {
                throw new Exception("bNb.Sec: " + ec.ToString());
            }
            return(hProv);
        }
Exemple #11
0
 public static IntPtr AcquireContext(string provName, ProvType provType, ContextFlag conFlag)
 {
     return(AcquireContext(null, provName, provType, conFlag));
 }