21.03.2013 Views

Problem - Kevin Tafuro

Problem - Kevin Tafuro

Problem - Kevin Tafuro

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Table 7-2. Math operations supported by OpenSSL’s BIGNUM library (continued)<br />

Function Description Limitations Comments<br />

r = a×2 Fastest way to multiply by 2.<br />

int BN_lshift1(BIGNUM *r,<br />

BIGNUM *a);<br />

int BN_lshift(BIGNUM *r,<br />

BIGNUM *a, int n);<br />

int BN_rshift1(BIGNUM *r,<br />

BIGNUM *a);<br />

int BN_rshift(BIGNUM *r,<br />

BIGNUM *a, int n);<br />

int BN_sqr(BIGNUM *r, BIGNUM<br />

*a, BN_CTX *ctx);<br />

int BN_exp(BIGNUM *r, BIGNUM<br />

*a, BIGNUM *p, BN_CTX *ctx);<br />

int BN_div(BIGNUM *d, BIGNUM<br />

*r, BIGNUM *a, BIGNUM *b, BN_<br />

CTX *ctx);<br />

int BN_mod(BIGNUM *r, BIGNUM<br />

*a, BIGNUM *b, BN_CTX *ctx);<br />

int BN_nnmod(BIGNUM *r,<br />

BIGNUM *a, BIGNUM *b, BN_CTX<br />

*ctx);<br />

int BN_mod_add(BIGNUM *r,<br />

BIGNUM *a, BIGNUM *b, BIGNUM<br />

*m, BN_CTX *ctx);<br />

int BN_mod_sub(BIGNUM *r,<br />

BIGNUM *a, BIGNUM *b, BIGNUM<br />

*m, BN_CTX *ctx);<br />

int BN_mod_mul(BIGNUM *r,<br />

BIGNUM *a, BIGNUM *b, BIGNUM<br />

*m, BN_CTX *ctx);<br />

int BN_mod_sqr(BIGNUM *r,<br />

BIGNUM *a, BIGNUM *b, BIGNUM<br />

*m, BN_CTX *ctx);<br />

int BN_mod_exp(BIGNUM *r,<br />

BIGNUM *a, BIGNUM *p, BIGNUM<br />

*m, BN_CTX *ctx);<br />

BIGNUM *BN_mod_<br />

inverse(BIGNUM *r, BIGNUM<br />

*a, BIGNUM *m, BN_CTX *ctx);<br />

int BN_gcd(BIGNUM *r, BIGNUM<br />

*a, BIGNUM *b, BN_CTX *ctx);<br />

int BN_add_word(BIGNUM *a,<br />

BN_ULONG w);<br />

int BN_sub_word(BIGNUM *a,<br />

BN_ULONG w);<br />

int BN_mul_word(BIGNUM *a,<br />

BN_ULONG *a);<br />

322 | Chapter 7: Public Key Cryptography<br />

r = a×2n Fastest way to multiply by a<br />

power of 2 where n>1.<br />

r = a÷2 Fastest way to divide by 2.<br />

r=a÷2n Fastest way to divide by a<br />

power of 2 where n>1.<br />

r = a×a Faster than BN_mul.<br />

r = a p r≠a, r≠p Values may be the same, but<br />

the objects may not be.<br />

d = a÷b<br />

r = a mod b<br />

d≠a, d≠b, r≠a, r≠b Values may be the same, but<br />

the objects may not be;<br />

either d or r may be NULL.<br />

r = a mod b r≠a, r≠b Values may be the same, but<br />

the objects may not be.<br />

r = |a mod b| r≠a, r≠b Values may be the same, but<br />

the objects may not be.<br />

r = |a+b mod m| r≠a, r≠b, r≠m Values may be the same, but<br />

the objects may not be.<br />

r = |a-b mod m| r≠a, r≠b, r≠m Values may be the same, but<br />

the objects may not be.<br />

r = |a×b mod m| r≠a, r≠b, r≠m Values may be the same, but<br />

the objects may not be.<br />

r = |a×a mod m| r≠a, r≠m Values may be the same, but<br />

the objects may not be.<br />

Faster than BN_mod_mul.<br />

r = |ap mod m| r≠a, r≠p, r≠m Values may be the same, but<br />

the objects may not be.<br />

Returns NULL on error, such<br />

as when no modular inverse<br />

exists.<br />

r = GCD(a,b) Greatest common divisor.<br />

a = a+w<br />

a = a-w<br />

a = a×w<br />

This is the Title of the Book, eMatter Edition<br />

Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!