예제 #1
0
 public void Dispose()
 {
     if (this._handle != null)
     {
         _CIPHER.EVP_CIPHER_CTX_cleanup(this._handle);
         _CIPHER.EVP_CIPHER_CTX_free(this._handle);
     }
     this._handle = null;
 }
예제 #2
0
        public CIPHER(CType type, CMode mode, bool encrypt)
        {
            EVP_CIPHER *    cipher = null; // Statically allocated (MT), don't free
            EVP_CIPHER_CTX *handle = null;

            try {
                cipher = (EVP_CIPHER *)_ciphers[new Tuple <CType, CMode>(type, mode)]();
            } catch (KeyNotFoundException) {}

            if (cipher == null)
            {
                goto Bailout;
            }

            if ((handle = _CIPHER.EVP_CIPHER_CTX_new()) == null)
            {
                goto Bailout;
            }
            _CIPHER.EVP_CIPHER_CTX_init(handle);
            if (_CIPHER.EVP_CipherInit_ex(handle, cipher, IntPtr.Zero, null, null, encrypt ? 1 : 0) == 0)
            {
                goto Bailout;
            }
            _CIPHER.EVP_CIPHER_CTX_set_padding(handle, 0);

            this._handle  = handle;
            this._type    = type;
            this._mode    = mode;
            this._encrypt = encrypt;

            return;

Bailout:
            if (handle != null)
            {
                _CIPHER.EVP_CIPHER_CTX_free(handle);
            }
            throw new EVPException();
        }
예제 #3
0
 public static extern int EVP_CIPHER_CTX_set_iv_length(EVP_CIPHER_CTX *handle, int length);
예제 #4
0
 public static extern int EVP_CIPHER_CTX_block_size(EVP_CIPHER_CTX *handle);
예제 #5
0
 public static extern int EVP_CIPHER_CTX_iv_length(EVP_CIPHER_CTX *handle);
예제 #6
0
 public static extern void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *handle);
예제 #7
0
 public static extern EVP_CIPHER *EVP_CIPHER_CTX_cipher(EVP_CIPHER_CTX *handle);
예제 #8
0
 public static extern int EVP_CipherUpdate(EVP_CIPHER_CTX *handle, byte[] outbuf, ref int outlen, byte[] inbuf, int inlen);
예제 #9
0
 public static extern int EVP_CipherUpdate(EVP_CIPHER_CTX *handle, IntPtr outbuf, ref int outlen, IntPtr inbuf, int inlen);
예제 #10
0
 public static extern int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *handle, int type, int arg, byte[] ptr);
예제 #11
0
 public static extern int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *handle, int type, int arg, IntPtr ptr);
예제 #12
0
 public static extern int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *handle, int padding);
예제 #13
0
 public static extern int EVP_CipherInit_ex(EVP_CIPHER_CTX *handle, EVP_CIPHER *cipher, IntPtr engine, byte[] key, byte[] iv, int enc);
예제 #14
0
 public static extern void EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *handle);
예제 #15
0
파일: OpenSSL.cs 프로젝트: haf/miTLS
 public void Dispose()
 {
     if (this._handle != null) {
         _CIPHER.EVP_CIPHER_CTX_cleanup(this._handle);
         _CIPHER.EVP_CIPHER_CTX_free(this._handle);
     }
     this._handle = null;
 }
예제 #16
0
 public static extern int EVP_CipherFinal_ex(EVP_CIPHER_CTX *handle, IntPtr outbuf, ref int outlen);
예제 #17
0
파일: OpenSSL.cs 프로젝트: haf/miTLS
        public SCIPHER(SType type, bool encrypt)
        {
            EVP_CIPHER *cipher = null; // Statically allocated (MT), don't free
            EVP_CIPHER_CTX *handle = null;

            try {
                cipher = (EVP_CIPHER*) _ciphers[type]();
            } catch (KeyNotFoundException) {}

            if (cipher == null)
                goto Bailout;

            if ((handle = _CIPHER.EVP_CIPHER_CTX_new()) == null)
                goto Bailout;
            _CIPHER.EVP_CIPHER_CTX_init(handle);
            if (_CIPHER.EVP_CipherInit_ex(handle, cipher, IntPtr.Zero, null, null, encrypt ? 1 : 0) == 0)
                goto Bailout;
            _CIPHER.EVP_CIPHER_CTX_set_padding(handle, 0);

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

            return ;

        Bailout:
            if (handle != null)
                _CIPHER.EVP_CIPHER_CTX_free(handle);
            throw new EVPException();
        }
예제 #18
0
 public static extern void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *handle);