monotone

monotone Mtn Source Tree

Root/botan/basefilt.cpp

1/*************************************************
2* Basic Filters Source File *
3* (C) 1999-2005 The Botan Project *
4*************************************************/
5
6#include <botan/basefilt.h>
7
8namespace Botan {
9
10/*************************************************
11* Chain Constructor *
12*************************************************/
13Chain::Chain(Filter* f1, Filter* f2, Filter* f3, Filter* f4)
14 {
15 if(f1) { attach(f1); incr_owns(); }
16 if(f2) { attach(f2); incr_owns(); }
17 if(f3) { attach(f3); incr_owns(); }
18 if(f4) { attach(f4); incr_owns(); }
19 }
20
21/*************************************************
22* Chain Constructor *
23*************************************************/
24Chain::Chain(Filter* filters[], u32bit count)
25 {
26 for(u32bit j = 0; j != count; j++)
27 if(filters[j])
28 {
29 attach(filters[j]);
30 incr_owns();
31 }
32 }
33
34/*************************************************
35* Fork Constructor *
36*************************************************/
37Fork::Fork(Filter* f1, Filter* f2, Filter* f3, Filter* f4)
38 {
39 Filter* filters[4] = { f1, f2, f3, f4 };
40 set_next(filters, 4);
41 }
42
43/*************************************************
44* Fork Constructor *
45*************************************************/
46Fork::Fork(Filter* filters[], u32bit count)
47 {
48 set_next(filters, count);
49 }
50
51/*************************************************
52* Set the algorithm key *
53*************************************************/
54void Keyed_Filter::set_key(const SymmetricKey& key)
55 {
56 if(base_ptr)
57 base_ptr->set_key(key);
58 else
59 throw Invalid_State("Keyed_Filter::set_key: No base algorithm set");
60 }
61
62/*************************************************
63* Check if a keylength is valid *
64*************************************************/
65bool Keyed_Filter::valid_keylength(u32bit n) const
66 {
67 if(base_ptr)
68 return base_ptr->valid_keylength(n);
69 throw Invalid_State("Keyed_Filter::valid_keylength: No base algorithm set");
70 }
71
72}

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status