Efficient arithmetic on ARM-NEON and its application for high-speed RSA implementation

Hwajeong Seo, Zhe Liu, Johann Großschädl, Howon Kim

TL;DR

This paper introduces highly optimized algorithms for multi-precision squaring and multiplication specifically designed for ARM-NEON SIMD architectures. By leveraging a novel "Double Operand Scanning" (DOS) technique and integrating Karatsuba’s method with vector instructions, the authors achieved a 30% speedup in RSA encryption on the Cortex-A15 platform compared to previous state-of-the-art implementations.

What Problem Does This Paper Address?

Public-key cryptography—the backbone of secure internet communication (RSA, ECC, DSA)—relies heavily on modular arithmetic with very large integers (e.g., 2048-bit). These operations are computationally expensive, especially on embedded devices.

While modern processors include SIMD (Single Instruction Multiple Data) units like ARM-NEON to accelerate math, traditional cryptographic software often fails to utilize them fully. Existing approaches frequently run into two walls:

  1. Read-After-Write (RAW) Dependencies: Pipeline stalls occur when an instruction has to wait for a previous one to finish writing to a register.
  2. Redundant vs. Non-Redundant Representations: Many SIMD implementations use "redundant" formats to handle carries easily, but these require more memory and more partial products, making them inefficient for the very long integers used in RSA.

Furthermore, most research has focused on multiplication, even though squaring accounts for roughly 80% of the workload in RSA exponentiation.

Methods

The authors propose a suite of new techniques optimized for non-redundant representations:

  • Double Operand Scanning (DOS) Squaring: Traditionally, squaring is optimized by calculating $A[i] \times A[j]$ once and doubling it. However, doubling the intermediate result in SIMD causes massive carry-propagation delays. The DOS method instead doubles the operands in advance. This allows the squaring to be computed in an integrated way that avoids RAW dependencies and pipeline stalls.
  • Karatsuba Cascade Operand Scanning (KCOS/KDOS): The authors adapt the Karatsuba algorithm (which reduces one $n$-bit multiplication into three $n/2$-bit multiplications) for SIMD. They specifically use the subtractive Karatsuba method for squaring to avoid the overhead of sign-checking.
  • Separated Montgomery Algorithm: Instead of interleaving multiplication and modular reduction (which is difficult to parallelize with Karatsuba), they use a "separated" approach. This allows them to use their high-speed KCOS/KDOS routines for the multiplication phase.
  • Hybrid SISD/SIMD Approach: Recognizing that SIMD isn't always faster, the authors use standard SISD (Single Instruction Single Data) instructions for final carry alignments and subtractions, where sequential logic and lower latency are more beneficial than raw parallel throughput.

Datasets

As this is a cryptographic engineering paper, the "datasets" consist of performance benchmarks on specific hardware:

  • Target Platforms: ARM Cortex-A9 and Cortex-A15 processors.
  • Benchmarks: The algorithms were tested on integer lengths of 512, 1024, 2048, 4096, and 8192 bits.
  • Comparison Points: Results were compared against the GNU Multiple Precision (GMP) library (v6.0.0a), OpenSSL (v1.0.2), and previous academic implementations (e.g., Seo et al. from ICISC 2014).

Key Insights and Ideas

  • Pre-Doubling is Better than Post-Doubling: In the context of SIMD squaring, doubling the input operands is a "eureka" moment. It sidesteps the chain of carry-propagations that usually plagues squaring optimizations on vector processors.
  • The "Sweet Spot" for Karatsuba: While Karatsuba is asymptotically faster, its overhead often makes it slower for smaller integers. By integrating it with "Cascade Operand Scanning," the authors found a way to make it efficient even for 1024-bit and 2048-bit RSA operations.
  • Instruction Mixing: The paper highlights that "pure" SIMD isn't always the answer. Using SISD for the "tail end" of calculations (like final carry handling) significantly reduces latency.

Key Results

The performance gains on the Cortex-A15 platform are substantial:

  • Multiplication/Squaring: Improved by 22% and 41% respectively over previous best-known results.
  • Montgomery Operations: Separated Montgomery multiplication and squaring were 25% and 33% faster.
  • RSA-2048 Encryption: Achieved a 30% speedup, requiring only 367,408 clock cycles.
  • Comparison to GMP: For 512-bit operations, their methods were roughly 50% faster than the highly-optimized GMP library.

Limitations and Future Work

  • Platform Specificity: The current implementation is highly tuned for the ARMv7 architecture (Cortex-A9/A15). While the authors suggest the logic is applicable to Intel-AVX and Intel-SSE, they have not yet provided implementations or benchmarks for those platforms.
  • Side-Channel Analysis: While the authors mention "constant-time" Karatsuba to prevent timing attacks, the paper does not provide an exhaustive side-channel analysis (like power or electromagnetic analysis) which is often required for high-security hardware deployments.
  • Future Work: The authors plan to port these routines to Intel-SSE and Intel-AVX to see if the DOS and KCOS techniques provide similar "boundary-pushing" results on x86 architectures.

Summary updated

BibTeX
@inproceedings{seo2016efficient,
  author = {Hwajeong Seo and Zhe Liu and Johann Großschädl and Howon Kim},
  title = {{Efficient arithmetic on ARM-NEON and its application for high-speed RSA implementation}},
  booktitle = {Secur. Commun. Networks},
  year = {2016},
  url = {https://openreview.net/forum?id=1_xFQRPW1nj},
}
Figure