Home Forums ActiveX components Xceed Encryption for ActiveX How to check if a file is encrypted?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #42870 |

    Is there any way to determine if wheter or not a file is encryted?
    I try to open it a read it, but it does not seem to be a “clean” solution.
    Thanks so much for you help

    Imported from legacy forums. Posted by dsuarez (had 11380 views)

    User (Old forums)
    Member
    Post count: 23064

    Did you ever get a response to this? I am looking to do the same thing. Thanks.

    Imported from legacy forums. Posted by AZMerf (had 443 views)

    User (Old forums)
    Member
    Post count: 23064

    Better late than never…

    Is there any way to determine if wheter or not a file is encryted?

    The short answer is : no. If it was otherwise, it could mean that the encryption algorithm was broken. The goal of the encryption is to produce gibberish. The result has to look like a random chunk of data. Furthermore, as you seem to have found, the Xceed Encryption Library will silently “decrypt” anything as long that its length is a multiple of 128 bits (AES block size). This is by design. That said, I can see three solutions to your problem:

    1) The dumb one. As previously said, an encrypted chunk will always have a size that is a multiple of 16 bytes. Furthermore, it will never be shorter than 32 bytes if you use the RFC1423 or FIPS81 padding method. If, on top of this, you use the recommended ChainedBlocks encryption mode, the data will never be shorter than 48 bytes. You can check this but, evidently, if the data complies to these rules, it will prove nothing. We can call this a probability check! It may be sufficient to fill your needs, although I doubt it.

    2) Prepend or append some bytes to the encrypted data (unencrypted header or footer). This is useful if you decide to allow different encryption algorithms, key sizes, encryption modes, … You can store these informations in the header and later extract these various parameters in order to initiliaze your decryption process.

    3) Make an encrypted encryption header. Obviously, this header will be the first bytes to be encrypted and decrypted. Checking if a data chunk is encrypted is then simply a matter of decrypting the first few blocks and verifying if the decrypted data match your header signature. A header can contain, for example : the header version number (and/or signature), the size of the plain text (useful if you’re using the random padding method), the original name of the file (if you decide to encrypt the file name), …

    I hope that helps… if you’re still listening

    Imported from legacy forums. Posted by Michel (had 4986 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.