view dcrypt/crypto/StreamCipherWrapper.d @ 4:3de3a2de13a0

Added MAC base class and HMAC. Added StreamCipherWrapper as part of the work on the high-level cipher API. Running on fumes, so hopefully there isn't too much stupid mixed into the code.
author Thomas Dixon <reikon@reikon.us>
date Thu, 14 Aug 2008 01:45:24 -0400
parents
children
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.StreamCipherWrapper;

import dcrypt.crypto.SymmetricCipher;
import dcrypt.crypto.StreamCipher;
public import dcrypt.crypto.params.CipherParameters;

/** High-level API for stream ciphers. */
class StreamCipherWrapper : SymmetricCipher {
    private StreamCipher cipher;
    
    this(StreamCipher sc) {
        cipher = sc;
    }
    
    void init(bool encrypt, CipherParameters params) {
        cipher.init(encrypt, params);
    }

    uint update(void[] input_, uint inOff, 
                    uint len, void[] output_, uint outOff) {
        cipher.processBytes(input_, inOff, len, output_, outOff);
        return len;
    }
    
    uint finish(void[] output_, uint outOff) {
        return 0;
    }
    
    void reset() {
        cipher.reset();
    }
    
    char[] name() {
        return cipher.name;
    }
}