Search code examples
phplinuxencryptioncapicom

Capicom Decryption in Linux


I have a database that encrypted with windows CAPICOM library with RC4. Following PHP script works fine on windows server.

    ...
$oCapiCapi = new COM("CAPICOM.EncryptedData");
$oCapiCapi -> Algorithm = 1;
$oCapiCapi -> Algorithm -> KeyLength = 3;
$oCapiCapi -> SetSecret('OURveRYSecretKey');
    ...
    $oCapiCapi -> Decrypt($orsd[1]);
    $Decrypted = $oCapiCapi -> Content;
    ...

I would like to decrypt the same database on linux server. How Should I do that? Can I decrypt the a data that encrypted with CAPICOM?

Thank you.


Solution

  • CAPICOM uses standard encryption algorithms such as 3DES. If you parse the encrypted buffers yourself, you should be able to decode them using any language.

    For details on CAPICOM buffers, start here: http://www.jensign.com/JavaScience/dotnet/DeriveBytes/index.html

    If you're dealing with data from a single source using only one crypto algorithm, you should be able to simplify your buffer parsing code significantly.