Mercurial > projects > dcrypt
diff dcrypt/crypto/params/ParametersWithIV.d @ 0:0e08791a1418
Initial import.
author | Thomas Dixon <reikon@reikon.us> |
---|---|
date | Sun, 10 Aug 2008 14:20:17 -0400 |
parents | |
children | 71aae178f89a |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dcrypt/crypto/params/ParametersWithIV.d Sun Aug 10 14:20:17 2008 -0400 @@ -0,0 +1,63 @@ +/** + * This file is part of the dcrypt project. + * + * Copyright: Copyright (C) dcrypt contributors 2008. All rights reserved. + * License: MIT + * Authors: Thomas Dixon + */ + +module dcrypt.crypto.params.ParametersWithIV; + +public import dcrypt.crypto.params.CipherParameters; + +/** Wrap cipher parameters and IV. */ +class ParametersWithIV : CipherParameters { + private ubyte[] m_iv; + private CipherParameters m_params; + + /** + * Params: + * params = Parameters to wrap. + * iv = IV to be held. + */ + this(CipherParameters params=null, ubyte[] iv_=null) { + if (params) + m_params = params; + ubyte[] iv = cast(ubyte[]) iv_; + if (iv) + m_iv = iv; + } + + /** Returns: The IV. */ + ubyte[] iv() { + return m_iv; + } + + /** + * Set the IV held by this object. + * + * Params: + * newIV = The new IV for this parameter object. + * Returns: The new IV. + */ + ubyte[] iv(void[] newIV_) { + ubyte[] newIV = cast(ubyte[]) newIV_; + return m_iv = newIV; + } + + /** Returns: The parameters for this object. */ + CipherParameters parameters() { + return m_params; + } + + /** + * Set the parameters held by this object. + * + * Params: + * newParams = The new parameters to be held. + * Returns: The new parameters. + */ + CipherParameters parameters(CipherParameters newParams) { + return m_params = newParams; + } +}