InterviewStack.io LogoInterviewStack.io

Cryptographic Algorithm Implementation Questions

Skills and knowledge for correctly implementing cryptographic algorithms and primitives in code. Candidates should be able to translate algorithm specifications and mathematical definitions into correct implementations, handling binary data layouts, bit operations such as shifts and exclusive or, and large integer arithmetic required for modular operations. Expect to implement core operations and components including Advanced Encryption Standard encryption rounds, Rivest Shamir Adleman modular exponentiation, Secure Hash Algorithm 256 message scheduling, substitution boxes in block ciphers, mixing functions, substitution and permutation operations, and simplified cipher operations for demonstration. Understand appropriate data structure choices and their performance and security implications, including constant time considerations, endianness, padding rules, and proper randomness. Implement and verify against official test vectors and build verification procedures and test harnesses. Emphasize correctness and clear explanation over premature optimization and recognize when to prefer well vetted cryptographic libraries to custom implementations.

EasyTechnical
72 practiced
Implement multi-limb addition: write a C function add_n(uint64_t *r, const uint64_t *a, const uint64_t *b, size_t n) that adds two n-limb unsigned integers stored as little-endian arrays of 64-bit limbs, stores the n-limb result in r, and returns the final carry (0 or 1). Ensure correct carry propagation and discuss constant-time considerations for cryptographic use.
EasyTechnical
81 practiced
Implement a simple stream cipher wrapper in Python that XORs plaintext with a provided keystream generator function. Spec: keystream(n) -> bytes returns n keystream bytes; implement encrypt(plaintext, keystream). Show how to reuse the wrapper for encryption and decryption and explain why reusing the same keystream for multiple messages is dangerous.
HardTechnical
61 practiced
Implement the SHA-256 compression function in C: given an initial 8-word state and a single 512-bit block, compute the updated state after processing that block according to the standard. Your implementation must include message schedule generation, the 64 rounds with K constants, and correct big-endian handling. Describe tests you would run and micro-optimizations you consider safe.
HardSystem Design
81 practiced
Design a C library API for symmetric encryption primitives that reduces developer misuse. Define function prototypes for one-shot and streaming use, error handling conventions, an opaque key type with lifecycle functions (allocate/zero/free), and how to advertise constant-time guarantees. Provide an example usage for AES-GCM and HKDF and explain how you would document and test the API.
EasyTechnical
73 practiced
Implement rotate-left and rotate-right operations for 32-bit and 64-bit unsigned integers in C with well-defined behavior for all rotate amounts (including 0). Provide portable implementations and mention how you would use compiler intrinsics or assembly for performance when available.

Unlock Full Question Bank

Get access to hundreds of Cryptographic Algorithm Implementation interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.