]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Removed RC5 encryption, not compatible with older crypto libs
authoranwleung <anwleung@29311d96-e01e-0410-9327-a35deaab8ce9>
Fri, 23 Feb 2007 04:32:59 +0000 (04:32 +0000)
committeranwleung <anwleung@29311d96-e01e-0410-9327-a35deaab8ce9>
Fri, 23 Feb 2007 04:32:59 +0000 (04:32 +0000)
git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1120 29311d96-e01e-0410-9327-a35deaab8ce9

branches/aleung/security1/ceph/crypto/CryptoLib.cc
branches/aleung/security1/ceph/crypto/CryptoLib.h
branches/aleung/security1/ceph/crypto/driver.cc
branches/aleung/security1/ceph/mds/Locker.cc

index 26b2cec093794294f7c9b95e0c79092b9a821255..82b50ad5e1043b6a87bf407c5d5730be41420e5c 100644 (file)
@@ -24,12 +24,14 @@ using namespace std;
  * block ciphers. This returns a encryptor mode
  * for encrypting using AC5.
  **********/
+/*
 CryptoLib::cfbRC5Enc CryptoLib::getRC5Enc(byte* key,
                                          const unsigned int keyLen,
                                          byte* iv) {
   cfbRC5Enc cfbEncryption(key, keyLen, iv);
   return cfbEncryption;
 }
+*/
 
 /**********
  * Generates a Cipher Feedback Mode
@@ -37,32 +39,38 @@ CryptoLib::cfbRC5Enc CryptoLib::getRC5Enc(byte* key,
  * block ciphers. This returns a decryptor mode
  * for decrypting using RC5.
  **********/
+/*
 CryptoLib::cfbRC5Dec CryptoLib::getRC5Dec(byte* key,
                                               const unsigned int keyLen,
                                               byte* iv) {
   cfbRC5Dec cfbDecryption(key, keyLen, iv);
   return cfbDecryption;
 }
+*/
 
 /**********
  * Encrypts a block of data using Rijndael.
  * This assumes the out buffer is already
  * allocated to the right size.
  **********/
+/*
 void CryptoLib::encryptRC5(byte* plain, const unsigned int plainLen,
                           byte* cipher, CryptoLib::cfbRC5Enc cfbEncryption) {
   cfbEncryption.ProcessData(cipher, plain, plainLen);
 }
+*/
 
 /**********
  * Decrypts a block of data using Rijndael.
  * This assumes the out buffer is already
  * allocated to the right size.
  **********/
+/*
 void CryptoLib::decryptRC5(byte* cipher, const unsigned int cipherLen,
                           byte* plain, CryptoLib::cfbRC5Dec cfbDecryption) {
   cfbDecryption.ProcessData(plain, cipher, cipherLen);
 }
+*/
 
 /**********
  * Generates a Cipher Feedback Mode
index 9521f5b8d033960b3b83d9c3df718fdb7562cd3c..b483762a52796cacb82dc0e9423dda61de404204 100644 (file)
@@ -30,7 +30,7 @@
 #include<crypto++/esign.h>
 //encryption/decryption
 #include<crypto++/modes.h>
-#include<crypto++/rc5.h>
+//#include<crypto++/rc5.h>
 #include<crypto++/aes.h>
 #include<crypto++/rijndael.h>
 
@@ -57,18 +57,20 @@ namespace CryptoLib {
   typedef CryptoPP::RSASSA_PKCS1v15_SHA_Verifier rsaPub;
   typedef CryptoPP::CFB_Mode<CryptoPP::Rijndael>::Encryption cfbModeEnc;
   typedef CryptoPP::CFB_Mode<CryptoPP::Rijndael>::Decryption cfbModeDec;
-  typedef CryptoPP::CFB_Mode<CryptoPP::RC5>::Encryption cfbRC5Enc;
-  typedef CryptoPP::CFB_Mode<CryptoPP::RC5>::Decryption cfbRC5Dec;
+  //typedef CryptoPP::CFB_Mode<CryptoPP::RC5>::Encryption cfbRC5Enc;
+  //typedef CryptoPP::CFB_Mode<CryptoPP::RC5>::Decryption cfbRC5Dec;
 
   // symmetric block modes
   cfbModeEnc getCFBModeEnc(byte*, const unsigned int, byte*);
   cfbModeDec getCFBModeDec(byte*, const unsigned int, byte*);
   void encryptCFB(byte*, const unsigned int, byte*, cfbModeEnc);
   void decryptCFB(byte*, const unsigned int, byte*, cfbModeDec);
+  /*
   cfbRC5Enc getRC5Enc(byte*, const unsigned int, byte*);
   cfbRC5Dec getRC5Dec(byte*, const unsigned int, byte*);
   void encryptRC5(byte*, const unsigned int, byte*, cfbRC5Enc);
   void decryptRC5(byte*, const unsigned int, byte*, cfbRC5Dec);
+  */
 
   // asymmetric key generation
   esignPriv esignPrivKey(char*);
index d587766af71b61b403127b449d86845095a935e7..54eeaeba2d3b70a680925d05889fab947438a555 100644 (file)
@@ -165,6 +165,7 @@ int main(int argc, char* argv[]) {
   decryptCFB(cipherMsg, plainLen, origMsg, myDec);
   cout << "My recovered message is " << origMsg << endl;
 
+  /*
   // RC5 encryption/decryption
   byte plainRC5[] = "My RC5 message to encrypt is even longer now";
   unsigned int plainRC5len = strlen((const char*)plainRC5)+1;
@@ -197,133 +198,6 @@ int main(int argc, char* argv[]) {
   //decrypt
   decryptRC5(cipherRC5, plainRC5len, recoverRC5, decRC5);
   cout << "My recovered message is " << recoverRC5 << endl;
-
-  /*
-  CryptoLib myCryptoLib;
-  myCryptoLib.sha1(msg,digest,strlen((const char*)msg));
-  myCryptoLib.toHex(digest, digestHex, CryptoLib::SHA1DIGESTSIZE, 2*CryptoLib::SHA1DIGESTSIZE);
-  cout << "SHA-1 of " << msg << " is " << string((const char*)digestHex,2*CryptoLib::SHA1DIGESTSIZE) << endl;
-
-  // sha-256
-  byte digest256[CryptoLib::SHA256DIGESTSIZE];
-  byte hex256[2*CryptoLib::SHA256DIGESTSIZE];
-  myCryptoLib.sha256(msg, digest256, strlen((const char*)msg));
-  myCryptoLib.toHex(digest256, hex256, CryptoLib::SHA256DIGESTSIZE, 2*CryptoLib::SHA256DIGESTSIZE);
-  cout << "SHA-256 of " << msg << " is " << string((const char*)hex256,2*CryptoLib::SHA256DIGESTSIZE) << endl;
-
-  // sha-384
-  byte digest384[CryptoLib::SHA384DIGESTSIZE];
-  byte hex384[2*CryptoLib::SHA384DIGESTSIZE];
-  myCryptoLib.sha384(msg, digest384, strlen((const char*)msg));
-  myCryptoLib.toHex(digest384, hex384, CryptoLib::SHA384DIGESTSIZE, 2*CryptoLib::SHA384DIGESTSIZE);
-  cout << "SHA-384 of " << msg << " is " << string((const char*)hex384,2*CryptoLib::SHA384DIGESTSIZE) << endl;
-
-  // sha-512
-  byte digest512[CryptoLib::SHA512DIGESTSIZE];
-  byte hex512[2*CryptoLib::SHA512DIGESTSIZE];
-  myCryptoLib.sha512(msg, digest512, strlen((const char*)msg));
-  myCryptoLib.toHex(digest512, hex512, CryptoLib::SHA512DIGESTSIZE, 2*CryptoLib::SHA512DIGESTSIZE);
-  cout << "SHA-512 of " << msg << " is " << string((const char*)hex512,2*CryptoLib::SHA512DIGESTSIZE) << endl;
-
-  // md5
-  byte digestmd5[CryptoLib::MD5DIGESTSIZE];
-  byte hexmd5[2*CryptoLib::MD5DIGESTSIZE];
-  myCryptoLib.md5(msg, digestmd5, strlen((const char*)msg));
-  myCryptoLib.toHex(digestmd5, hexmd5, CryptoLib::MD5DIGESTSIZE, 2*CryptoLib::MD5DIGESTSIZE);
-  cout << "MD5 of " << msg << " is " << string((const char*)hexmd5,2*CryptoLib::MD5DIGESTSIZE) << endl;
-
-  // esign signature
-  byte* signMsg = (byte *)"Message to sign";
-  char* keyInput = "esig1536.dat";
-  CryptoLib::esignPriv privKey = myCryptoLib.esignPrivKey(keyInput);
-  CryptoLib::esignPub pubKey = myCryptoLib.esignPubKey(privKey);
-  CryptoLib::SigBuf mySignature = myCryptoLib.esignSig(signMsg, strlen((const char*)signMsg), privKey);
-  if (myCryptoLib.esignVer(signMsg, strlen((const char*)signMsg), mySignature, pubKey))
-    cout << "ESIGN signature verification SUCCEDED" << endl;
-  else
-    cout << "ESIGN signature verification FAILED" << endl;
-
-  // RSA signature
-  byte* rsaMsg = (byte *)"Message to sign";
-  char* rsaInput = "rsa1024.dat";
-  CryptoLib::rsaPriv privRSAKey = myCryptoLib.rsaPrivKey(rsaInput);
-  CryptoLib::rsaPub pubRSAKey = myCryptoLib.rsaPubKey(privRSAKey);
-  CryptoLib::SigBuf myRSASignature = myCryptoLib.rsaSig(rsaMsg, strlen((const char*)rsaMsg), privRSAKey);
-  if (myCryptoLib.rsaVer(rsaMsg, strlen((const char*)rsaMsg), myRSASignature, pubRSAKey))
-    cout << "RSA signature verification SUCCEDED" << endl;
-  else
-    cout << "RSA signature verification FAILED" << endl;
-  
-  // Rijndael encryption/decryption
-  byte* plainMsg = (byte *)"My message to encrypt is even longer now";
-  // the +1 is because strlen doesn't capture null char
-  unsigned int plainLen = strlen((const char*)plainMsg)+1;
-  cout << "About to encrypt " << plainMsg << " of size " << plainLen << endl;
-
-  // intializes my key and iv
-  byte encKey[CryptoLib::RJ128KEYSIZE];
-  byte iv[CryptoLib::RJBLOCKSIZE];
-  memset(encKey, 0x01, CryptoLib::RJ128KEYSIZE);
-  memset(iv, 0x01, CryptoLib::RJBLOCKSIZE);
-
-  // initialize my cipher buffer
-  byte cipherMsg[plainLen];
-  memset(cipherMsg, 0x00, plainLen);
-  
-  // setup my encryptors and decryptors
-  CryptoLib::cfbModeEnc myEnc = myCryptoLib.getCFBModeEnc(encKey, CryptoLib::RJ128KEYSIZE, iv);
-  CryptoLib::cfbModeDec myDec = myCryptoLib.getCFBModeDec(encKey, CryptoLib::RJ128KEYSIZE, iv);
-
-  // perform encryption
-  myCryptoLib.encryptCFB(plainMsg, plainLen, cipherMsg, myEnc);
-
-  // turn my cipher into hex
-  // the +1 is capture the end of the cipher buffer
-  byte cipherHex[(2*plainLen)+1];
-  memset(cipherHex, 0x00, (2*plainLen)+1);
-  myCryptoLib.toHex(cipherMsg, cipherHex, plainLen, (2*plainLen)+1);
-  cout << "My ciphertext has size " << strlen((const char*)cipherMsg) << endl;
-  cout << "Rijndael cipher of " << plainMsg << " is " << cipherHex << endl;
-
-  // recover my data
-  byte origMsg[plainLen];
-  memset(origMsg, 0x00, plainLen);
-  myCryptoLib.decryptCFB(cipherMsg, plainLen, origMsg, myDec);
-  cout << "My recovered message is " << origMsg << endl;
-
-
-  // RC5 encryption/decryption
-  byte plainRC5[] = "My message to encrypt is even longer now";
-  unsigned int plainRC5len = strlen((const char*)plainRC5)+1;
-  
-  // initialize my cipher/hex/recover buffers
-  byte cipherRC5[plainRC5len];
-  byte hexRC5[(2*plainRC5len)+1];
-  byte recoverRC5[plainRC5len];
-  memset(cipherRC5, 0x00, plainRC5len);
-  memset(hexRC5, 0x00, (2*plainRC5len)+1);
-  memset(recoverRC5, 0x00, plainRC5len);
-
-  // init key and IV
-  byte keyRC5[CryptoLib::RC5KEYSIZE];
-  byte ivRC5[CryptoLib::RC5BLOCKSIZE];
-  memset(keyRC5, 0x01, CryptoLib::RC5KEYSIZE);
-  memset(ivRC5, 0x01, CryptoLib::RC5BLOCKSIZE);
-  
-  // init encrpytors and decryptors
-  CryptoLib::cfbRC5Enc encRC5 = myCryptoLib.getRC5Enc(keyRC5, CryptoLib::RC5KEYSIZE, ivRC5);
-  CryptoLib::cfbRC5Dec decRC5 = myCryptoLib.getRC5Dec(keyRC5, CryptoLib::RC5KEYSIZE, ivRC5);
-
-  // encrypt
-  myCryptoLib.encryptRC5(plainRC5, plainRC5len, cipherRC5, encRC5);
-
-  // convert to hex
-  myCryptoLib.toHex(cipherRC5, hexRC5, plainRC5len, (2*plainRC5len)+1);
-  cout << "RC5 cipher of " << plainRC5 << " is " << hexRC5 << endl;
-
-  //decrypt
-  myCryptoLib.decryptRC5(cipherRC5, plainRC5len, recoverRC5, decRC5);
-  cout << "My recovered message is " << recoverRC5 << endl;
   */
   return 0;
 }
index b182bb411bc92e2ab867cbabedba308954f76567..d9a827bb07b3c30c2ddd5cd58001f4f9f53b1779 100644 (file)
@@ -190,7 +190,6 @@ ExtCap* Locker::issue_new_extcaps(CInode *in, int mode, MClientRequest *req) {
   dout(3) << "issue_new_EXTcaps for mode " << mode << " on " << *in << endl;
 
   // get the uid
-  int my_client = req->get_client();
   uid_t my_user = req->get_caller_uid();
   int my_want = 0;
   // issue most generic cap (RW)