view dcrypt/crypto/params/SymmetricKey.d @ 2:71aae178f89a

Added copy() to hash functions. Modified some code style.
author Thomas Dixon <reikon@reikon.us>
date Wed, 13 Aug 2008 22:01:19 -0400
parents 0e08791a1418
children 5ce3012f1def
line wrap: on
line source

/**
 * 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.SymmetricKey;

import dcrypt.crypto.params.CipherParameters;

/** Object representing and wrapping a symmetric key in bytes. */
class SymmetricKey : CipherParameters {
    private ubyte[] m_key;
    
    /**
     * Params:
     *     key = Key to be held.
     */
    this(void[] key_=null) {
        ubyte[] key = cast(ubyte[]) key_;
        if (key)
            m_key = key;
    }
    
    /** Returns: Key in ubytes held by this object. */
    ubyte[] key() {
        return m_key;
    }
    
    /**
     * Set the key held by this object.
     *
     * Params:
     *     newKey = New key to be held.
     * Returns: The new key.
     */
    ubyte[] key(void[] newKey_) {
        ubyte[] newKey = cast(ubyte[])newKey_;
        return m_key = newKey;
    }
}