GetMD() static private méthode

static private GetMD ( MDType type ) : EVP_MD*
type MDType
Résultat EVP_MD*
Exemple #1
0
        public MD(MDType type)
        {
            EVP_MD *    md     = null; // Statically allocated (MT), don't free
            EVP_MD_CTX *handle = null;

            if ((md = MD.GetMD(type)) == null)
            {
                throw new EVPException();
            }

            if ((handle = _MD.EVP_MD_CTX_create()) == null)
            {
                goto Bailout;
            }

            if (_MD.EVP_DigestInit_ex(handle, md, IntPtr.Zero) == 0)
            {
                goto Bailout;
            }

            this._handle = handle;
            this._type   = type;

            return;

Bailout:
            if (handle != null)
            {
                _MD.EVP_MD_CTX_destroy(handle);
            }
            throw new EVPException();
        }
Exemple #2
0
        public HMAC(MDType type)
        {
            this._type = type;
            this._md   = MD.GetMD(this._type);

            if (this._md == null)
            {
                throw new EVPException();
            }
        }