|
SASC
DVBSoftCAM
|
00001 /* 00002 * Softcam plugin to VDR (C++) 00003 * 00004 * This code is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This code is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html 00018 */ 00019 00020 #ifndef ___CRYPTO_BN_H 00021 #define ___CRYPTO_BN_H 00022 00023 #include <openssl/bn.h> 00024 00025 // ---------------------------------------------------------------- 00026 00027 void RotateBytes(unsigned char *in, int n); 00028 void RotateBytes(unsigned char *out, const unsigned char *in, int n); 00029 00030 // ---------------------------------------------------------------- 00031 00032 class cBN { 00033 private: 00034 BIGNUM big; 00035 public: 00036 cBN(void) { BN_init(&big); } 00037 ~cBN() { BN_free(&big); } 00038 operator BIGNUM* () { return &big; } 00039 BIGNUM *operator->() { return &big; } 00040 BIGNUM *BN(void) { return &big; } 00041 bool Get(const unsigned char *in, int n); 00042 bool GetLE(const unsigned char *in, int n); 00043 int Put(unsigned char *out, int n) const; 00044 int PutLE(unsigned char *out, int n) const; 00045 }; 00046 00047 class cBNctx { 00048 private: 00049 BN_CTX *ctx; 00050 public: 00051 cBNctx(void) { ctx=BN_CTX_new(); } 00052 ~cBNctx() { BN_CTX_free(ctx); } 00053 operator BN_CTX* () { return ctx; } 00054 }; 00055 00056 #endif //___CRYPTO_BN_H