Search code examples
clinuxwindowsoptimizationcryptoapi

Cryptographic API vs manually implemented algorithm


I tried to search across the internet, but was unable to find something. So question is: What is better to use? OS provided cryptographic API or manually implemented/library provided algorithms?

I know that, when CPU enters in kernel mode after OS system call, it consumes large amount of CPU cycles, but on the other hand I know that OS can use hardware accerelated cryptography. So what is situation in real world? Is it worth to use OS Cryptographic API?

For example project that I work on, uses CRC32 and MD5 algorithms.

EDIT: My primary goal is to select fastest approach and secondary is to know all cons and pros.


Solution

  • MD5 is probably available everywhere. CRC32 is so simple (and not really cryptography) that you can just include or implement it directly in your application.

    The Windows crypto API supports multiple providers and the default provider is probably fully implemented in user mode without switching to kernel mode for most things. The PRng and AES encryption might be implemented in hardware.

    What is your goal? Speed? No backdoors? Obscure algorithms?