"Fossies" - the Fresh Open Source Software Archive

Member "krb5-1.18/src/lib/crypto/builtin/aes/aescpp.h" (12 Feb 2020, 1936 Bytes) of package /linux/misc/krb5-1.18.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "aescpp.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * Copyright (c) 2001, Dr Brian Gladman <brg@gladman.uk.net>, Worcester, UK.
    3  * All rights reserved.
    4  *
    5  * TERMS
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted subject to the following conditions:
    9  *
   10  *  1. Redistributions of source code must retain the above copyright
   11  *     notice, this list of conditions and the following disclaimer.
   12  *
   13  *  2. Redistributions in binary form must reproduce the above copyright
   14  *     notice, this list of conditions and the following disclaimer in the
   15  *     documentation and/or other materials provided with the distribution.
   16  *
   17  *  3. The copyright holder's name must not be used to endorse or promote
   18  *     any products derived from this software without his specific prior
   19  *     written permission.
   20  *
   21  * This software is provided 'as is' with no express or implied warranties
   22  * of correctness or fitness for purpose.
   23  */
   24 
   25 /*
   26  * Issue Date: 21/01/2002
   27  *
   28  * This file contains the definitions required to use AES (Rijndael) in C++.
   29  */
   30 
   31 #ifndef _AESCPP_H
   32 #define _AESCPP_H
   33 
   34 #include "aes.h"
   35 
   36 class AESclass
   37 {   aes_ctx cx[1];
   38 public:
   39 #if defined(BLOCK_SIZE)
   40     AESclass()                          { cx->n_blk = BLOCK_SIZE; cx->n_rnd = 0; }
   41 #else
   42     AESclass(unsigned int blen = 16)    { cx->n_blk = blen; cx->n_rnd = 0; }
   43 #endif
   44     aes_rval blk_len(unsigned int blen) { return aes_blk_len(blen, cx); }
   45     aes_rval enc_key(const unsigned char in_key[], unsigned int klen)
   46             { return aes_enc_key(in_key, klen, cx); }
   47     aes_rval dec_key(const unsigned char in_key[], unsigned int klen)
   48             { return aes_dec_key(in_key, klen, cx); }
   49     aes_rval enc_blk(const unsigned char in_blk[], unsigned char out_blk[])
   50             { return aes_enc_blk(in_blk, out_blk, cx); }
   51     aes_rval dec_blk(const unsigned char in_blk[], unsigned char out_blk[])
   52             { return aes_dec_blk(in_blk, out_blk, cx); }
   53 };
   54 
   55 #endif