Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

DO IN ASSEMMBLY A common operation in cryptography is to compute c = x e , where e is a constant. A typical choice for

DO IN ASSEMMBLY A common operation in cryptography is to compute c=xe, where e is a constant. A typical choice for e is
the value 65537=216+1 because there exists a fast assembly routine for this value using a technique called
repeated squaring.
Repeated squaring can be used to quickly calculate exponents that are a power of two. For example, x4 can
be computed as (x2)2 using two imul q instructions. Similarly, x216 can be computed using sixteen imul q
instructions.
The routine works like this:
Save x in a temporary variable (such as a register).
Compute y=x216 using repeated squaring and store y in another temporary variable (such as another
register).
Return z=x*y, which is x65537 because x*x216=x216+1 by the laws of exponents.
Implement this fast exponentiation routine in x86-64 assembly. You must use a loop for the repeated squar-
ing, properly align memory, follow x86-64 register conventions, and provide a comment for each assembly
instruction.
You should use assume that e=65537 is a constant and imulq instructions will not overflow. ?1 The only
parameter will be x. You do not have to implement any test cases.
An example function prototype in C for your implementation is as follows:
// Compute x-65537
int64_t fast_exponentiate (int64_t x);
Some example calls:
fast_exponentiate (0)
fast_exponentiate(2)
fast_exponentiate(17)
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Informix Database Administrators Survival Guide

Authors: Joe Lumbley

1st Edition

0131243144, 978-0131243149

More Books

Students also viewed these Databases questions

Question

3. Provide advice on how to help a plateaued employee.

Answered: 1 week ago