Our Online Store have the new products: RFID antenna board. Currently it can work with JC10M24R and JCOP4 card chips.
Compared with normal cards, the antenna board module has a smaller size and fixed holes, which is easy to integrate in the IOT(Internet Of Things) project.

How to implement os2ip and i2osp as per PKCS#1 specification in javacard?

JavaCard Applet Development Related Questions and Answers.
nikhilnick23
Posts: 3
Joined: Thu Jan 23, 2020 8:37 am
Points :74
Contact:

How to implement os2ip and i2osp as per PKCS#1 specification in javacard?

Post by nikhilnick23 » Wed Jan 29, 2020 1:55 am

Hello Friends,

I need to perform the following conversions(as per PKCS#1) in javacard:

I2OSP converts a nonnegative integer to an octet string of a specified length.

I2OSP (x, xLen)
Input:
x nonnegative integer to be converted
xLen intended length of the resulting octet string
Output:
X corresponding octet string of length xLen
Error: "integer too large"
Steps:
1. If x >= 256^xLen, output "integer too large" and stop.
2. Write the integer x in its unique xLen-digit representation in
base 256:

x = x_(xLen-1) 256^(xLen-1) + x_(xLen-2) 256^(xLen-2) + ...
+ x_1 256 + x_0,

where 0 <= x_i < 256 (note that one or more leading digits
will be zero if x is less than 256^(xLen-1)).
3. Let the octet X_i have the integer value x_(xLen-i) for 1 <= i
<= xLen. Output the octet string

X = X_1 X_2 ... X_xLen.

OS2IP converts an octet string to a nonnegative integer.

OS2IP (X)
Input: X octet string to be converted
Output: x corresponding nonnegative integer
Steps:
1. Let X_1 X_2 ... X_xLen be the octets of X from first to last,
and let x_(xLen-i) be the integer value of the octet X_i for 1
<= i <= xLen.
2. Let x = x_(xLen-1) 256^(xLen-1) + x_(xLen-2) 256^(xLen-2) +
... + x_1 256 + x_0.
3. Output x.

In java there is one class BigInterger which we can use to perform both arithmetic and modulo arithmetic operations on Big integer values.

But how do we implement the same in case of javacard ? Although there is one class BigNumber which we can may be use to perform arithmetic operations(but no modulo arithmetic operations) on big integers values but its limitation is only upto 8 bytes what about really big integer values like 150-160 digits long ?

Who is online

Users browsing this forum: No registered users and 58 guests

JavaCard OS : Disclaimer