Net.Pkcs11Interop.HighLevelAPI81.MechanismParams.CkRsaPkcsOaepParams.ToMarshalableStructure C# (CSharp) Method

ToMarshalableStructure() public method

Returns managed object that can be marshaled to an unmanaged block of memory
public ToMarshalableStructure ( ) : object
return object
        public object ToMarshalableStructure()
        {
            if (this._disposed)
                throw new ObjectDisposedException(this.GetType().FullName);

            return _lowLevelStruct;
        }
        

Usage Example

        /// <summary>
        /// Initializes a new instance of the CkAesCbcEncryptDataParams class.
        /// </summary>
        /// <param name='aesKeyBits'>Length of the temporary AES key in bits</param>
        /// <param name='oaepParams'>Parameters of the temporary AES key wrapping</param>
        public CkRsaAesKeyWrapParams(NativeULong aesKeyBits, CkRsaPkcsOaepParams oaepParams)
        {
            _lowLevelStruct.AESKeyBits = 0;
            _lowLevelStruct.OAEPParams = IntPtr.Zero;

            if (oaepParams == null)
            {
                throw new ArgumentNullException("oaepParams");
            }

            // Keep the reference to OAEP params so GC will not free it while this object exists
            _oaepParams = oaepParams;

            _lowLevelStruct.AESKeyBits = aesKeyBits;

            _lowLevelStruct.OAEPParams = UnmanagedMemory.Allocate(UnmanagedMemory.SizeOf(typeof(CK_RSA_PKCS_OAEP_PARAMS)));
            UnmanagedMemory.Write(_lowLevelStruct.OAEPParams, oaepParams.ToMarshalableStructure());
        }