4

I have been playing around with the Credit cards (saved) payment option and noticed it encrypts the credit card numbers. What algorithm is it using? What are the specifics? I quite interested to see what method they are using.

Note: I am not going to use the Credit card (saved) payment option on my live site. I understand it is a huge security issue. I am just curious about how strong of encryption it uses!

1
  • 1
    Check out app/code/core/Mage/Core/Model/Encryption.php. The encrypt function there looks to be what's called when it saves credit card information. It also references lib/Varien/Crypt, but I'm certainly no expert at deciphering this stuff and how good it is.
    – Don
    Commented Aug 13, 2014 at 19:31

1 Answer 1

7

According to Magento:

Strong Data Encryption, Hashing and Key Management Strong data encryption based on AES-256 and strong hashing based on SHA-256. Database keys are easily managed and updated.

From my understanding and some quick glances at code:

Community is mainly Mcrypt and Blowfish (ECB Mode) based, as Don pointed out in the comments.

Enterprise uses a custom class for PCI compliance which uses both Mcrypt and Blowfish as with different cyphers and stronger encryption.

MCRYPT_RIJNDAEL_128,MCRYPT_RIJNDAEL_256,HASH_VERSION_SHA256,etc.

Both using a combination of MD5, salting and hashes.

You can override the encryption models if you wished to use your own:

 /**
 * @return Mage_Core_Model_Encryption
 */
public function getEncryptor()
{
    if ($this->_encryptor === null) {
        $encryptionModel = (string)Mage::getConfig()->getNode(self::XML_PATH_ENCRYPTION_MODEL);
        if ($encryptionModel) {
            $this->_encryptor = new $encryptionModel;
        } else {
            $this->_encryptor = Mage::getModel('core/encryption');
        }

        $this->_encryptor->setHelper($this);
    }
    return $this->_encryptor;
}

With that said, storing Credit Card data makes you a target and future legal issues possibly.

However I have seen scrapping hacks that are capturing data input before it is encrypted and logging it. So simply not storing them makes you immune either. This is proof that other exploits outside of Magento in its stack should always be considered.

As far as encryption strength, that would be a better question for:

Other related documents to read:

2
  • 1
    Really interesting. I was actually able to go this site to decrypt credit card information. With my encryption key I set the algorithm to Blowfish, mode to ECB, and Decode the input using Base 64 I was able to decrypt a credit card number from my database. Does this mean my encryption method is using blowfish? tools4noobs.com/online_tools/decrypt
    – SKilme
    Commented Aug 13, 2014 at 21:14
  • github.com/OpenMage/magento-mirror/blob/magento-1.9/lib/Varien/… Yes, my initial answer may be incorrect as Mcrypt is used with Blowfish as well.
    – B00MER
    Commented Aug 14, 2014 at 22:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.