javaextensions/satsa/crypto/src/stssymmetriccipher.h
branchRCL_3
changeset 14 04becd199f91
equal deleted inserted replaced
13:f5050f1da672 14:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Base class for cipher algorithms which implements
       
    15  *                CSymmetricCipher.
       
    16  *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef STSSYMMETRICCIPHER_H
       
    21 #define STSSYMMETRICCIPHER_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <string>
       
    25 
       
    26 #include <openssl/evp.h>
       
    27 #include "stscipher.h"
       
    28 
       
    29 using namespace std;
       
    30 
       
    31 // CONSTANTS
       
    32 class CSymmetricCipher;
       
    33 class CBlockTransformation;
       
    34 class CPadding;
       
    35 
       
    36 namespace java
       
    37 {
       
    38 namespace satsa
       
    39 {
       
    40 // CLASS DECLARATION
       
    41 /**
       
    42  *  Base class for cipher algorithms which implements CSymmetricCipher.
       
    43  *  For every algorithm key validity must be checked in the subclasses
       
    44  *  because initialization with wrong size key causes a panic.
       
    45  *
       
    46  */
       
    47 class STSSymmetricCipher: public STSCipher
       
    48 {
       
    49 public:
       
    50     // Constructors and destructor
       
    51 
       
    52     /**
       
    53      * Destructor.
       
    54      */
       
    55     ~STSSymmetricCipher();
       
    56 
       
    57     static STSSymmetricCipher* Create(STSTransformation* aTransformation,
       
    58                                       int* errCode);
       
    59 
       
    60 public:
       
    61     // Functions from STSCipher
       
    62 
       
    63     jint DoInit(JNIEnv* aJni, const TCipherMode aMode,
       
    64                 const jstring aKeyAlgorithm, const jstring aKeyFormat,
       
    65                 const jbyteArray aKeyEncoded, const jbyteArray aParams);
       
    66 
       
    67     jint DoFinal(JNIEnv* aJni, jbyteArray aInput, jint aInputOffset,
       
    68                  jint aInputLength, jbyteArray aOutput, jint aOutputOffset);
       
    69 
       
    70     jint Update(JNIEnv* aJni, jbyteArray aInput, jint aInputOffset,
       
    71                 jint aInputLength, jbyteArray aOutput, jint aOutputOffset);
       
    72 
       
    73 protected:
       
    74 
       
    75     /**
       
    76      * C++ default constructor.
       
    77      */
       
    78     STSSymmetricCipher();
       
    79 
       
    80     int Construct(STSTransformation* aTransformation);
       
    81 
       
    82 private:
       
    83 
       
    84     // Provides symmetric cipher functionality.
       
    85     CSymmetricCipher* mCipher;
       
    86 
       
    87     // Bytes processed using Update method. Value is reset to 0 in Init
       
    88     // method.
       
    89     int mBytesProcessed;
       
    90 
       
    91     EVP_CIPHER_CTX *mCipherCtx;
       
    92     const EVP_CIPHER *mCipherType;
       
    93 
       
    94 };
       
    95 } // namespace satsa
       
    96 } // namespace java
       
    97 #endif // STSSYMMETRICCIPHER_H
       
    98 // End of File