Skip to content

Commit

Permalink
Merge pull request #18 from invisal/decrypt-using-crt-algorithm
Browse files Browse the repository at this point in the history
Using Chinese Remainder Theorem
  • Loading branch information
invisal authored Dec 9, 2020
2 parents fb9b801 + 5e7cd38 commit c9836f1
Show file tree
Hide file tree
Showing 41 changed files with 467 additions and 86 deletions.
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@
"editor.tabSize": 2,
"deno.enable": true,
"files.eol": "\n",
"editor.formatOnSave": true,
"[typescript]": {
"editor.defaultFormatter": "denoland.vscode-deno"
}
}
61 changes: 61 additions & 0 deletions benchmark/rsa_decryption.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { RSAKey } from "../src/rsa/rsa_key.ts";
import { RSA } from "./../mod.ts";

async function benchmark(
callback: () => Promise<void>,
time: number,
): Promise<string> {
const begin = Date.now();
for (let i = 0; i < time; i++) await callback();
const duration = Date.now() - begin;
return (
"Average time per operation: " +
(duration / time).toLocaleString(undefined, {
maximumFractionDigits: 3,
minimumFractionDigits: 3,
}) +
"ms"
);
}

const RSAWithoutCRT = new RSA(
new RSAKey({
n: 18860626341786571281488823024986320858450594409825894653370543036132043241142573896042059032222842653925236802058387508300831766517210547599910735316414515960981281788934868325895562621846910598716519620622800765932541992515497122274302135166053720433521886017494719475895327062855822141735315456613329660043977602681873027347568355824008701177948209784908095092287571982104446342906805480285143028837509076748632094733769028381835899214426100089454654381383340292544225149266603150745375542089871264998183586873913491071542891188124185517417658034185267204900711933432911892469528812455677450346478816563776340692357n,
e: 65537n,
d: 675889233296421535959584534071325460876697008626327098961835826056666939623318583538247287416696388446697983317835135300723690022117970081796395234018582764098060974026823771341271141202058228435371968592820841644512299636165137501280011132877728106486853881053264668544941537620562475421678333757690909726581512579603702598150422421865490996288244127528474781858718770957987603681469839575489191876915053252047160475432784849252000744700939988583801783684487872676506769116621572018367654125765915215495461243190782913460732307866572233187464540482209385816659449697777403383908159076257721991916366849321145825505n,
length: 256,
}),
);

const RSAWithCRT = new RSA(
new RSAKey({
n: 18860626341786571281488823024986320858450594409825894653370543036132043241142573896042059032222842653925236802058387508300831766517210547599910735316414515960981281788934868325895562621846910598716519620622800765932541992515497122274302135166053720433521886017494719475895327062855822141735315456613329660043977602681873027347568355824008701177948209784908095092287571982104446342906805480285143028837509076748632094733769028381835899214426100089454654381383340292544225149266603150745375542089871264998183586873913491071542891188124185517417658034185267204900711933432911892469528812455677450346478816563776340692357n,
e: 65537n,
d: 675889233296421535959584534071325460876697008626327098961835826056666939623318583538247287416696388446697983317835135300723690022117970081796395234018582764098060974026823771341271141202058228435371968592820841644512299636165137501280011132877728106486853881053264668544941537620562475421678333757690909726581512579603702598150422421865490996288244127528474781858718770957987603681469839575489191876915053252047160475432784849252000744700939988583801783684487872676506769116621572018367654125765915215495461243190782913460732307866572233187464540482209385816659449697777403383908159076257721991916366849321145825505n,
p: 144012741627856144888308881334281149724189531338704225677876939563376606824918324031374859287124236226502971065990666108124651521772921507380585859955952240309460362784798071545709251190489395954672667468167440559860853869293126718717957973299492588051948353555478537074738121854154013245465025431728566135973n,
q: 130964983574331118238688281723343099404807798188351894743739498160286888632365582428908430826736465978859171109808627043780421532713284022169182243601628532694521039146449170161837408903716062502861857136295244082497345869098293182658740508141543051039696970285876309414793236229439985580214897811694398138209n,
dp:
101745242578283949839304176626026302615765501625718038014206601700771528284898122271399648057012472126577972233967069321732572665229256933255045035440751035763135842618089328298662278539176953652032498422434484837613519933106647440836151945919299110608989008748123460390840662802554879248234151815614020617785n,
dq:
35678301062546466652937128368533312430740473760697540759490440516864704054843143700287335764233224950585953598646920476061700200574682590472688401624478932858201910873563078628399913004363131970125205568021351112332081315087369371243559409682455859030208122243679686715774576798456162206832122091795348953409n,
qi:
290194643186456996857651131997752205887237030546449364256620415456526041634563025067464278896891532150660234750257681796597575941847755684751705687345792123358974007946764700824215929859573834912100325612311985272735079519163425874861676228607347917173236103665132111683625679969874392886475792638645717652n,
length: 256,
}),
);

const ciper = await RSAWithCRT.encrypt("Hello World");

console.log(
"With CRT",
await benchmark(async () => {
RSAWithCRT.decrypt(ciper);
}, 1000),
);

console.log(
"Without CRT",
await benchmark(async () => {
RSAWithoutCRT.decrypt(ciper);
}, 1000),
);
67 changes: 47 additions & 20 deletions src/rsa/rsa_internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { i2osp, os2ip } from "./primitives.ts";
import { concat, random_bytes } from "./../helper.ts";
import { ber_decode, ber_simple } from "./basic_encoding_rule.ts";
import { RawBinary } from "../binary.ts";
import { RSAKey } from "./rsa_key.ts";

/**
* @param n public key modulus
Expand All @@ -19,8 +20,25 @@ export function rsaep(n: bigint, e: bigint, m: bigint): bigint {
* @param d private key exponent
* @param c ciphertext representative
*/
export function rsadp(n: bigint, d: bigint, c: bigint): bigint {
return power_mod(c, d, n);
export function rsadp(key: RSAKey, c: bigint): bigint {
if (!key.d) throw "Invalid RSA key";

if (key.dp && key.dq && key.qi && key.q && key.p) {
// Using the Chinese remainder algorithm
const m1 = power_mod(c % key.p, key.dp, key.p);
const m2 = power_mod(c % key.q, key.dq, key.q);

let h = 0n;
if (m1 >= m2) {
h = (key.qi * (m1 - m2)) % key.p;
} else {
h = (key.qi * (m1 - m2 + key.p * (key.p / key.q))) % key.p;
}

return (m2 + h * key.q) % (key.q * key.p);
} else {
return power_mod(c, key.d, key.n);
}
}

export function rsa_oaep_encrypt(
Expand All @@ -37,17 +55,15 @@ export function rsa_oaep_encrypt(
}

export function rsa_oaep_decrypt(
bytes: number,
n: bigint,
d: bigint,
key: RSAKey,
c: Uint8Array,
algorithm: "sha1" | "sha256",
) {
const em = rsadp(n, d, os2ip(c));
const em = rsadp(key, os2ip(c));
const m = eme_oaep_decode(
new Uint8Array(0),
i2osp(em, bytes),
bytes,
i2osp(em, key.length),
key.length,
algorithm,
);
return m;
Expand All @@ -65,13 +81,8 @@ export function rsa_pkcs1_encrypt(
return i2osp(c, bytes);
}

export function rsa_pkcs1_decrypt(
bytes: number,
n: bigint,
d: bigint,
c: Uint8Array,
) {
const em = i2osp(rsadp(n, d, os2ip(c)), bytes);
export function rsa_pkcs1_decrypt(key: RSAKey, c: Uint8Array) {
const em = i2osp(rsadp(key, os2ip(c)), key.length);

if (em[0] !== 0) throw "Decryption error";
if (em[1] !== 0x02) throw "Decryption error";
Expand All @@ -87,13 +98,13 @@ export function rsa_pkcs1_decrypt(
}

export function rsa_pkcs1_verify(
bytes: number,
n: bigint,
d: bigint,
key: RSAKey,
s: Uint8Array,
m: Uint8Array,
): boolean {
let em = i2osp(rsadp(n, d, os2ip(s)), bytes);
if (!key.e) throw "Invalid RSA key";

let em = i2osp(rsaep(key.n, key.e, os2ip(s)), key.length);

if (em[0] !== 0) throw "Decryption error";
if (em[1] !== 0x01) throw "Decryption error";
Expand Down Expand Up @@ -128,7 +139,23 @@ export function rsa_pkcs1_sign(
message: Uint8Array,
): RawBinary {
// deno-fmt-ignore
const oid = [0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00]
const oid = [
0x30,
0x0d,
0x06,
0x09,
0x60,
0x86,
0x48,
0x01,
0x65,
0x03,
0x04,
0x02,
0x01,
0x05,
0x00,
];
const der = [
0x30,
message.length + 2 + oid.length,
Expand Down
26 changes: 6 additions & 20 deletions src/rsa/rsa_js.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,9 @@ export class PureRSA {
if (!key.e) throw "Invalid RSA key";

if (options.padding === "oaep") {
return new RawBinary(rsa_oaep_encrypt(
key.length,
key.n,
key.e,
message,
options.hash,
));
return new RawBinary(
rsa_oaep_encrypt(key.length, key.n, key.e, message, options.hash),
);
} else if (options.padding === "pkcs1") {
return new RawBinary(
rsa_pkcs1_encrypt(key.length, key.n, key.e, message),
Expand All @@ -36,17 +32,9 @@ export class PureRSA {
if (!key.d) throw "Invalid RSA key";

if (options.padding === "oaep") {
return new RawBinary(rsa_oaep_decrypt(
key.length,
key.n,
key.d,
ciper,
options.hash,
));
return new RawBinary(rsa_oaep_decrypt(key, ciper, options.hash));
} else if (options.padding === "pkcs1") {
return new RawBinary(
rsa_pkcs1_decrypt(key.length, key.n, key.d, ciper),
);
return new RawBinary(rsa_pkcs1_decrypt(key, ciper));
}

throw "Invalid parameters";
Expand All @@ -61,9 +49,7 @@ export class PureRSA {
if (!key.e) throw "Invalid RSA key";

return rsa_pkcs1_verify(
key.length,
key.n,
key.e,
key,
signature,
createHash(options.hash).update(message).digest(),
);
Expand Down
2 changes: 2 additions & 0 deletions tests/rsa/cases/1024bit_1_ciper_oaep_sha1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
k�m��8e�5�_�q�U�!���)�ҡ[�! �  ��ku���όM��"Sȑ��&I܍�Ěb���:�}� p ��!m
�/���>?S�`b���ڟ�4����%��B_����y���Su
Expand Down
1 change: 1 addition & 0 deletions tests/rsa/cases/1024bit_1_ciper_oaep_sha256.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
�r=Q�G�5 ����\Sa�A�%\WzQ�z��b" ؐV���)���z[n�Ę��S[�f��",�p�W������z�g��R��ސ&�#���� �q�g����\������F���Ӈݵg�
Expand Down
Binary file added tests/rsa/cases/1024bit_1_ciper_pkcs1.txt
Binary file not shown.
15 changes: 15 additions & 0 deletions tests/rsa/cases/1024bit_1_private.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQCpvfLHP+BzLb/UYDBHL0vpH6qI0VLTZjSDtwxIxKbhckYaizED
J/0J3++hfAC1/Ge/7oe4nnpJJ8+I8K2I7gIJlx0494CrBZT9dNGq8smYgB5nW2D+
AgBIKAHwM65sh0ea4UnofRWwM8UMyPG+xzFqtdQTL0wJEJLm5RsVxaxxXwIDAQAB
AoGAV/xJAzU+MBXv0LNHcy62B5JNgHwYldHtuLTCnlmpM0Vbx1iNQFiTFnJIsYko
iSzbzqZjHbSwKImFTzOKkGbnEJ9mTMq+VdjShh86pyZPkylfRk7RJ/922a4hzq9Y
R4qfVFoWzo1gNLbnh3OtEHH9tTix3IIt0oDDF55SO1N3vvECQQDVAN6+6CCXnpCY
TVK73RwVjr2DLsD7KgMNWH6GHSyukAOZGuJL5l+pyvchS1LIZfefWpTB0lQif0Gq
abOYsLD5AkEAzAGCIWwVFnnrJC1Ng5C53xWnMPMqMKHEQ5fIC4wO3UUPu064/l1s
/GY0xNFDHtfvUhMtoMjSBX5fZiknO46jFwJAb9wKHjWnUBiclO8egLwokIWqrqax
//TbL3oG0AWoPnAxA4mjx/pOyMtnJxv4eHdcKFqYfoUnXAp6gLUL9SbteQJAW8KZ
67qXyaJRF9agtPrV//fXWfcmFPXON7D/s+Htla1IpDGGmDMhoG3Acn7FuAvcg4hI
z7dEcGAlPOhp0yoXRQJBALEyBkMqR/obqg1c4/0XJ4uQtjqjZkAljN45l1WFp9l6
VwNyQ7ARE8k3Rp80XLDb6LXabtoQmIePUOt8jc07zS8=
-----END RSA PRIVATE KEY-----
6 changes: 6 additions & 0 deletions tests/rsa/cases/1024bit_1_public.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCpvfLHP+BzLb/UYDBHL0vpH6qI
0VLTZjSDtwxIxKbhckYaizEDJ/0J3++hfAC1/Ge/7oe4nnpJJ8+I8K2I7gIJlx04
94CrBZT9dNGq8smYgB5nW2D+AgBIKAHwM65sh0ea4UnofRWwM8UMyPG+xzFqtdQT
L0wJEJLm5RsVxaxxXwIDAQAB
-----END PUBLIC KEY-----
2 changes: 2 additions & 0 deletions tests/rsa/cases/1024bit_2_ciper_oaep_sha1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
���7��u 1���:�q�v��t�b|ݪ-��,tR�Y:���Aܧ�q��:ƹ������3��
�f5E�q%��h��`��g��3��h�D'������R��Iq��<��`>�|'
Binary file added tests/rsa/cases/1024bit_2_ciper_oaep_sha256.txt
Binary file not shown.
2 changes: 2 additions & 0 deletions tests/rsa/cases/1024bit_2_ciper_pkcs1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
�\�G񛑆(
�rd�����S���ϳ������ �0�Im}�U7#�A���e�D!�֬A�a�C����o��ѫ!?&$g.ב~����.?���c�3�5�x„V$�G�p��oB��o�7Q/%o
15 changes: 15 additions & 0 deletions tests/rsa/cases/1024bit_2_private.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQDQaYtcXuUK1GW796VloxTrr+Kf81XX85BxsPtfyKa+ywzRYGUr
I4PO14RjkXtQV1Qlr42EngNqJGTcFtum5sWxgb1ZfbAWuC4HDJrX/41hzgijaMT9
i07twjt+UiQg9BJ6TguSxza5/IdJHFCR/f0S1fiMcr4KR9mxWF6ETpi1MQIDAQAB
AoGBALavfbhnejAnBFJi/vl7nXAHSgjZPStB1iDCeWZ5tShTRpYWADhzNivOoL7C
nKxNEHbETrGr7ORSqJJ/+uRvL2QXi8ybC/5SUaQCh2iDbMVazLWh38Rb8C+1Wx1u
rWmH0Yr6rm/X2LIAL6TUQVW9qyueKvnVye5+Mc1WPQRNRMiRAkEA6tv1yPMfyRC9
CIj8KKAGQQ7lCyTrZZJVwkBnmHlMu5Jq/cO5QVY5GFZM6OmxRZL9T1gmccmfBP3F
dDpnt1ZbBQJBAOMsJbqOLSuIaGJ7ro9d8Akwjc/bFr4+/HJRAJru2msZ2fiNbYBd
2bbpo9i3PzKuiSbJgNBTC/+pVx0T0AoiAT0CQCeG+ajmclUOwiHrnDTiKetNLHNh
tVSU+mYFHOpmj+mJzQQEqus6LcXQ0ITqv/ErugJenanM+zyF0XOsWMRcflkCQGPk
e8qmzjIAT3ZO0Jl2QyCnWxR1UHDjnXpfKBb4xM6nlXN4LRhvLFcEMeoP2hhdKy4F
GUGB4xrOyeGdXrO19DkCQDeM5zf4fho3pIByfA6bj2Gg/ocJ3N+/oB7TzVR5TP5S
3o4N3U+rEVtcDm1+m555Ji7n0b3WC1wu3M0FncUSF8Y=
-----END RSA PRIVATE KEY-----
6 changes: 6 additions & 0 deletions tests/rsa/cases/1024bit_2_public.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDQaYtcXuUK1GW796VloxTrr+Kf
81XX85BxsPtfyKa+ywzRYGUrI4PO14RjkXtQV1Qlr42EngNqJGTcFtum5sWxgb1Z
fbAWuC4HDJrX/41hzgijaMT9i07twjt+UiQg9BJ6TguSxza5/IdJHFCR/f0S1fiM
cr4KR9mxWF6ETpi1MQIDAQAB
-----END PUBLIC KEY-----
Binary file added tests/rsa/cases/2048bit_1_ciper_oaep_sha1.txt
Binary file not shown.
Binary file added tests/rsa/cases/2048bit_1_ciper_oaep_sha256.txt
Binary file not shown.
Binary file added tests/rsa/cases/2048bit_1_ciper_pkcs1.txt
Binary file not shown.
27 changes: 27 additions & 0 deletions tests/rsa/cases/2048bit_1_private.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEA0SQQqbw9EByOv65920q0+qHzAuxnvLyNYZUZm01lL1zrfg8V
T3NbSk+K0cNJIbEV5uoIt5fDT7i3hQP5WyA01m1xULZ/fFPPkAtBSv5oeNjdJpv4
a3iRWgRuKx1a0qMZNAMM37PZ90j42F3/hi2Q+xTcBpSbA7csvqzLTIzfgAw9mx7e
FJp+xxiLDfEElO9jnl8dKGcNaERkqDCcXolwb633qRzoc+GgYCNFUs0JzLWYWxtq
9UObXFWSOirYDaz4WuMzD3sxZgy0y4xk5NxYiOABx1jwg/otM0T2TwgbwIN9YIHH
toHbQhPS2+tH31mbzztorXY2yioKtCizJyqlUwIDAQABAoIBAQ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xlXM5Fm5cuFeIlU1G77xB7qAWPVD3WHOA+jt4FtDk2IkTqNAkmP
CZini7hdzvY3WXE2IqWvo7HwooUU29LJlBPsoHnnMwe8H+vQ1nCslQbsyR+P4Hrh
5RlrPs1/K2wjbe/uIDaHGCYfQX7PAwpts8BmFE50IQP0FBpHXpJMqv0=
-----END RSA PRIVATE KEY-----
9 changes: 9 additions & 0 deletions tests/rsa/cases/2048bit_1_public.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0SQQqbw9EByOv65920q0
+qHzAuxnvLyNYZUZm01lL1zrfg8VT3NbSk+K0cNJIbEV5uoIt5fDT7i3hQP5WyA0
1m1xULZ/fFPPkAtBSv5oeNjdJpv4a3iRWgRuKx1a0qMZNAMM37PZ90j42F3/hi2Q
+xTcBpSbA7csvqzLTIzfgAw9mx7eFJp+xxiLDfEElO9jnl8dKGcNaERkqDCcXolw
b633qRzoc+GgYCNFUs0JzLWYWxtq9UObXFWSOirYDaz4WuMzD3sxZgy0y4xk5NxY
iOABx1jwg/otM0T2TwgbwIN9YIHHtoHbQhPS2+tH31mbzztorXY2yioKtCizJyql
UwIDAQAB
-----END PUBLIC KEY-----
2 changes: 2 additions & 0 deletions tests/rsa/cases/2048bit_2_ciper_oaep_sha1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
K��N�4cA��3ҙx��H�������Z���n�r�PnM����;XS���%+�<��J��Ȃk���n�� �$zJ��u��$��hnW���~2P\�-�����6��.�#)�~�g�#�.u����M��O?� ð�d�m~Z��-b>rO:��yt
e��V�~�Q������`�]�Hfε%*~��7��WM��:���%b��~rx�jSJ��V^y�y+/�%�]�2Z���&Y�$����(�y���5 ��,�|�/�
Expand Down
1 change: 1 addition & 0 deletions tests/rsa/cases/2048bit_2_ciper_oaep_sha256.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
J٭X�[1��Zs���P���0�J�1�R9k���{���� ��4W��+��7�zk̰p�sr!?��C���*�OD�='���&��p8/��:0���2:�B�p^�\��<��>C����a�r�����K ���&n�� ��R�\Q8a���Kn��i�C��9�&��4m����Xʮ��՞0'.��=`{o�CA�CQ@�zs `2�#����` ���Ɣ���F=;�<���M����ovX=��f�xn|��w
Expand Down
2 changes: 2 additions & 0 deletions tests/rsa/cases/2048bit_2_ciper_pkcs1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
P{��@�}M��s�5I��=r&�-���a񴐧�k,�_Ҭ�Hc7;����ߋ �E<���X�`/��c����4 זN�ī��
Z�ᴚW�r�s���Hi�r�+��/�v����,wU}�+���T�۵�~|tE�9f�NA �IX<K2mS�[mQ�g����V�<?���`>Yr8�/<��Zz�m����;�w�)M����ֺ�"'�jN?�<�S��R14�i}�A�'������������;������
Expand Down
27 changes: 27 additions & 0 deletions tests/rsa/cases/2048bit_2_private.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEAvO45IgvaeViijFJNbmY8rcZL2cQwie0RKDBqxeCfgdSxOqSA
Rmp+myLhtmCgmg2pASh/IukPkHqnUKgoj2sfBgBRlLsPiWb1C/7QZFPXUFGETgWE
KFgomSFVVcLf27Qku3D0fRN37Wc3CONTwKI/NKp5lBa2b5tR46C9cI/51AhnkZgF
noAgqJDfmu1R4YuLtPuT822YE/ly+/VclxsMayeArzs23GdJnR7+jqG9HcISTque
YOHX8f0x8D35Pql3QIxfwWXb2Z+0wIjprKLDJWWJp3m6LrMf85nFABDnQ2DoT3xg
UUdh3aQrYAkvADNoPp4FOGfMpqTBEARQGB+nTQIDAQABAoIBAQCRIFUWyBAsgl9q
dpYwJayat+XwA3pdmJNDUd3S3nboXh89srsuXAOg26ySUatMaw3Va+wtPuXLz8vS
czmk4V5VV81S+FY477NwYW5mgti0Q8njvO0FqKKW7joExMr8k2Zb7aqAoYHQBSc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OJobfY3F5E=
-----END RSA PRIVATE KEY-----
9 changes: 9 additions & 0 deletions tests/rsa/cases/2048bit_2_public.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvO45IgvaeViijFJNbmY8
rcZL2cQwie0RKDBqxeCfgdSxOqSARmp+myLhtmCgmg2pASh/IukPkHqnUKgoj2sf
BgBRlLsPiWb1C/7QZFPXUFGETgWEKFgomSFVVcLf27Qku3D0fRN37Wc3CONTwKI/
NKp5lBa2b5tR46C9cI/51AhnkZgFnoAgqJDfmu1R4YuLtPuT822YE/ly+/VclxsM
ayeArzs23GdJnR7+jqG9HcISTqueYOHX8f0x8D35Pql3QIxfwWXb2Z+0wIjprKLD
JWWJp3m6LrMf85nFABDnQ2DoT3xgUUdh3aQrYAkvADNoPp4FOGfMpqTBEARQGB+n
TQIDAQAB
-----END PUBLIC KEY-----
Binary file added tests/rsa/cases/4096bit_1_ciper_oaep_sha1.txt
Binary file not shown.
Binary file added tests/rsa/cases/4096bit_1_ciper_oaep_sha256.txt
Binary file not shown.
Binary file added tests/rsa/cases/4096bit_1_ciper_pkcs1.txt
Binary file not shown.
Loading

0 comments on commit c9836f1

Please sign in to comment.