Main Page Modules Data Structures File List Data Fields Globals Related Pages

# beecrypt/blockmode.c

Go to the documentation of this file.

    00001
    00007 /*
    00008  * Copyright (c) 2000 Virtual Unlimited B.V.
    00009  *
    00010  * Author: Bob Deblier <bob@virtualunlimited.com>
    00011  *
    00012  * This library is free software; you can redistribute it and/or
    00013  * modify it under the terms of the GNU Lesser General Public
    00014  * License as published by the Free Software Foundation; either
    00015  * version 2.1 of the License, or (at your option) any later version.
    00016  *
    00017  * This library is distributed in the hope that it will be useful,
    00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00020  * Lesser General Public License for more details.
    00021  *
    00022  * You should have received a copy of the GNU Lesser General Public
    00023  * License along with this library; if not, write to the Free Software
    00024  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00025  *
    00026  */
    00027
    00028 #include "system.h"
    00029 #include "blockmode.h"
    00030 #include "mp32.h"
    00031 #include "debug.h"
    00032
    00033 int blockEncrypt(const blockCipher* bc, blockCipherParam* bp, cipherMode mode, int blocks, uint32* dst, const uint32* src)
    00034 {
    00035         if (bc->mode)
    00036         {
    00037                 register const blockMode* bm = bc->mode+mode;
    00038
    00039                 if (bm)
    00040                 {
    00041                         register const blockModeEncrypt be = bm->encrypt;
    00042
    00043                         if (be)
    00044                                 return be(bp, blocks, dst, src);
    00045                 }
    00046         }
    00047
    00048         return -1;
    00049 }
    00050
    00051 int blockDecrypt(const blockCipher* bc, blockCipherParam* bp, cipherMode mode, int blocks, uint32* dst, const uint32* src)
    00052 {
    00053         if (bc->mode)
    00054         {
    00055                 register const blockMode* bm = bc->mode+mode;
    00056
    00057                 if (bm)
    00058                 {
    00059                         register const blockModeEncrypt bd = bm->decrypt;
    00060
    00061                         if (bd)
    00062                                 return bd(bp, blocks, dst, src);
    00063                 }
    00064         }
    00065
    00066         return -1;
    00067 }