# Bitslice-DES optimization

**URL:** <https://forums.developer.nvidia.com/t/bitslice-des-optimization/38896>\
**Category:** CUDA Programming and Performance\
**Created:** [July 28, 2015, 3:05pm UTC](https://forums.developer.nvidia.com/t/bitslice-des-optimization/38896 "2015-07-28T15:05:50Z")\
**Posts on this page:** 1\
**Showing post:** 48

<div class="post-metadata">

**Author:** ![Clochette](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Clochette](https://forums.developer.nvidia.com/u/Clochette)\
**Post date:** [August 1, 2015, 7:18pm UTC](https://forums.developer.nvidia.com/t/bitslice-des-optimization/38896/48 "2015-08-01T19:18:54Z")

</div>

**(Warning: Maxwell only!)**

All codes are now open-sourced [here](https://github.com/DeepLearningJohnDoe/merikens-tripcode-engine/tree/PRV) as part of my personal fork of [Meriken’s Tripcode Engine](https://github.com/meriken2ch/merikens-tripcode-engine), a third-party tripcode finder for 10 character (DES crypt(3)) and 12 character (SHA-1) tripcodes.

Grab the following files if you are interested in:

**UNIX DES crypt(3) with salts:**

- DES\_Crypt\_##.h in [/MerikensTripcodeEngine/Source Files/out/](https://github.com/DeepLearningJohnDoe/merikens-tripcode-engine/tree/PRV/MerikensTripcodeEngine/Source%20Files/out), where ## ranges from 0 to 63. The 64 files contain 4096 functions DES\_Crypt\_###(), where ### ranges from 0 to 4095 and corresponds with the 12-bit salt value used to perturb the DES expansion function. 
- SBOXes: [sbox.h](https://github.com/DeepLearningJohnDoe/merikens-tripcode-engine/blob/PRV/MerikensTripcodeEngine/Source%20Files/sbox.h) in [/MerikensTripcodeEngine/Source Files/](https://github.com/DeepLearningJohnDoe/merikens-tripcode-engine/tree/PRV/MerikensTripcodeEngine/Source%20Files)
- Key-swapping macros: [keyswap.h](https://github.com/DeepLearningJohnDoe/merikens-tripcode-engine/blob/PRV/MerikensTripcodeEngine/Source%20Files/keyswap.h) in [/MerikensTripcodeEngine/Source Files/](https://github.com/DeepLearningJohnDoe/merikens-tripcode-engine/tree/PRV/MerikensTripcodeEngine/Source%20Files)

**One round of DES:**

- DES\_Crypt\_0() in [DES\_Crypt\_0.h](https://github.com/DeepLearningJohnDoe/merikens-tripcode-engine/blob/PRV/MerikensTripcodeEngine/Source%20Files/out/DES_Crypt_0.h) in [/MerikensTripcodeEngine/Source Files/out/](https://github.com/DeepLearningJohnDoe/merikens-tripcode-engine/tree/PRV/MerikensTripcodeEngine/Source%20Files/out), and manually remove the outer loop and the DATASWAP lines.
- SBOXes: [sbox.h](https://github.com/DeepLearningJohnDoe/merikens-tripcode-engine/blob/PRV/MerikensTripcodeEngine/Source%20Files/sbox.h) in [/MerikensTripcodeEngine/Source Files/](https://github.com/DeepLearningJohnDoe/merikens-tripcode-engine/tree/PRV/MerikensTripcodeEngine/Source%20Files)
- Key-swapping macros: [keyswap.h](https://github.com/DeepLearningJohnDoe/merikens-tripcode-engine/blob/PRV/MerikensTripcodeEngine/Source%20Files/keyswap.h) in [/MerikensTripcodeEngine/Source Files/](https://github.com/DeepLearningJohnDoe/merikens-tripcode-engine/tree/PRV/MerikensTripcodeEngine/Source%20Files)

Note: initial permutation and final permutation are not included in the function; you need to do it yourself. Normally they’re part of the pre-processing. Both have minimal performance impact.

Suggested register usage or launch bound is 168 regs, or\_\_launch\_bounds\_\_(128, 3), even when you wrap things around it.

With this version, I get a performance of **950 MH/s** for UNIX DES crypt(3) (or equivalently **23750 MH/s** for 1 round of DES) on my reference Gigabyte GTX 980 Ti (+270 MHz). Considering hashcat’s implementation gets [165.5 MH/s](http://hashcat.net/forum/thread-4314.html) on a GTX Titan X (+225 MHz), it’s a great improvement. Even my [naive implementation](https://github.com/DeepLearningJohnDoe/merikens-tripcode-engine/blob/master/MerikensTripcodeEngine/Source%20Files/CUDA10.cu#L1091) bounded by shared memory/synchronization with old SBOXes from JtR is faster (300 MH/s on 980 Ti +300 MHz).

This further dispelled the myth that Nvidia cards are still bad at DES crypt(3); while it may hold some truth before Maxwell (or even sm\_32, since it’s the first version that lift the register limit from 63 to 255) when compared against GCN, it’s no longer the case, and it all depends on the implementation.

---

_[View the full topic](https://forums.developer.nvidia.com/t/bitslice-des-optimization/38896)._
