Библиотека криптографических программ (CASIO fx-9750GP, cfx-9850GP, fx-9860G)

| рубрика «Программы» | автор basvic
Метки:

Библиотека этих программ позволяет освоить вычисления в криптографии с открытым ключом. Поддерживаются следующие виды вычислений.

  • Алгоритм RSA:
  • генерация ключей;
  • шифрование;
  • расшифровка;
  • цифровая подпись;
  • проверка цифровой подписи.
  • Алгоритм Эль-Гамаля:
    • генерация ключей;
    • шифрование;
    • расшифровка;
    • цифровая подпись;
    • проверка цифровой подписи.
  • Алгоритм Диффи-Хелмана:
    • генерация сеансового симметричного ключа.
  • Взлом шифра основанного на LFSR (регистре сдвига с линейными обратными связями)
  • Разложение числа на простые множители ро методом Полларда
  • Разложение числа на простые множители Р-1 методом Полларда
  • Криптография на эллиптических кривых:
  • сложение точек над эллиптической кривой;
  • умножение точки на число над эллиптической кривой;
  • алгоритм генерации симметричного сеансового ключа над эллиптической кривой;
  • цифровая подпись (и проверка подписи) над эллиптической кривой;
  • двухключевой шифр над эллиптической кривой.
  • Разложение числа на простые множители оптимизированным методом перебора.
  • Возведение целых чисел в степень по модулю.
  • Деление по модулю целого числа.
  • Проверка произвольного целого числа на простоту по теореме Ферма (не великой).
  • Криптографическая система Рабина (один из вариантов реализации).

После загрузки в калькулятор, запустить файл CRYPMAIN, а далее пользоваться подсказками меню. Поскольку в калькуляторе точность составляет 15 десятичных разрядов, то программа в обычных вычислениях работает с целыми числами до 7 разрядов включительно, а с эллиптическими кривыми - до 5 разрядов. В ходе работы используются все 28 регистров памяти, но поскольку их не достаточно, то задействованы ещё первые 30 ячеек списка List6 при вычислениях над эллиптическими кривыми.

В программах, в наиболее критичных местах введена "защита от дурака" в том смысле, что вводимые данные проходят проверку и если не удовлетворяют условиям, то отвергаются и запрашиваются повторно. Например, если надо ввести простое число, а оператор ввёл составное, то калькулятор это обнаружит и будет запрашивать число повторно.

Поскольку в калькуляторе нет кириллицы, то запросы и комментарии на латинице. Возможно словосочетания не самые удачные, но их можно подкорректировать.

Кто напишет это же под МК-161?

%Header Record
Format:TXT
Communication SW:0
Data Type:PG
Capacity:565
File Name:CRYPMAIN
Group Name:
Password:
Option1:NL
Option2:
Option3:
Option4:
%Data Record
"MAKED V.E.BASOV"\Disp\Do
\ClrText
"1\(-)RSA     2\(-)EL HAMAL"
"3\(-)LFSR    4\(-)DIFFIHEL"
"5\(-)RO POL  6\(-)P-1 POL"
"7\(-)ELLIPTIC 8-DIVMOD"
"9\(-)EXPMOD  0-FACTORIZ"
".\(-)TSTSIM <EXP>-RABIN"
"<EXIT>"
\Do
\Getkey\->X
\LpWhile X=0\ Or X=31
\If X=72
\Then \ClrText
\Prog "RSA"
0\->X
\IfEnd
\If X=62
\Then \ClrText
\Prog "EL HAMAL"
0\->X
\IfEnd
\If X=73
\Then \ClrText
\Prog "DIFFIHEL"
0\->X
\IfEnd
\If X=52
\Then \ClrText
\Prog "LFSRALT"
0\->X
\IfEnd
\If X=63
\Then \ClrText
\Prog "POLLARDR"
0\->X
\IfEnd
\If X=53
\Then \ClrText
\Prog "POLLARDP"
0\->X
\IfEnd
\If X=74
\Then \ClrText
\Prog "ELIPCALC"
0\->X
\IfEnd
\If X=64
\Then \ClrText
\Prog "DIV MOD"
0\->X
\IfEnd
\If X=71
\Then \ClrText
\Prog "FACTFAST"
0\->X
\IfEnd
\If X=61
\Then \ClrText
\Prog "TSTSIMPL"
0\->X
\IfEnd
\If X=51
\Then \ClrText
\Prog "RABIN"
0\->X
\IfEnd
\If X=54
\Then \ClrText
\Prog "EXP MOD"
0\->X
\IfEnd
\Stop
\LpWhile X\<>47
\Stop
%End
%Header Record
Format:TXT
Communication SW:0
Data Type:PG
Capacity:323
File Name:POLLARDR
Group Name:
Password:
Option1:NL
Option2:
Option3:
Option4:
%Data Record
\ClrText
"RO POLLARD"
"INPUT NUMBER"?\->C
128\->N
N\->\Dim \List 1
2\->\List 1[1]
\For 1\->I \To 254
\List 1[I]\->X
X\x^2+1\->X
X-C\Int (X/C)\->X
X\->\List 1[I+1]
\For I\->J \To 1 \Step \(-)1
\If \List 1[J]=X
\Then \Break
\IfEnd
\Next
\If J\<>1
\Then \List 1[I]\->X
\List 1[J-1]\->Y
X-Y+C\->X
X-C\Int (X/C)\->X
C\->Y
\Prog "SUB NOD"
C/X\->Y
\Break
\IfEnd
\Next
\If J>1\ And I<N-1
\Then "ITER="
"REPT="
"MUL1="
"MUL2="
\Locate 6,4,I+1
\Locate 6,5,J
\Locate 6,6,X
\Locate 6,7,Y
\Else "=LOW MEMORY="
\IfEnd
%End
%Header Record
Format:TXT
Communication SW:0
Data Type:PG
Capacity:54
File Name:EXP MOD
Group Name:
Password:
Option1:NL
Option2:
Option3:
Option4:
%Data Record
"A^B MOD C"
"A="?\->A
"B="?\->B
"C="?\->C
\Prog "SUB EXP"
D\Disp\Return
%End
%Header Record
Format:TXT
Communication SW:0
Data Type:PG
Capacity:82
File Name:DIV MOD
Group Name:
Password:
Option1:NL
Option2:
Option3:
Option4:
%Data Record
"A/B MOD C"
"A="?\->A
"B="?\->B
"C="?\->C
\Prog "SUB DIV"
\ClrText
"RES=":\Locate 5,1,D
"NOD=":\Locate 5,2,B
%End
%Header Record
Format:TXT
Communication SW:0
Data Type:PG
Capacity:430
File Name:ELIPCALC
Group Name:
Password:
Option1:NL
Option2:
Option3:
Option4:
%Data Record
"ELLIPTIC CALCULATOR"
\Prog "SB SETEL"
\Prog "SUB FNDP"
30\->\Dim \List 6
\Do
"G1="
\Locate 4,7,\r
\Locate 13,7,","
\Locate 14,7,\theta
"1 ADD POINTS"
"2 MULT POINT"
"3 DIFFI HELMAN"
"4 SIGNATURE"
"5 ENCRYPTION"
"6 CHANGE G  EXIT"
\Do
\Getkey\->X
\LpWhile X=0
\If X=72
\Then \Prog "SUB ADDP"
1\->X:\IfEnd
\If X=62
\Then \Prog "SUB MULP"
2\->X:\IfEnd
\If X=52
\Then \Prog "SUBMKKEY"
3\->X:\IfEnd
\If X=73
\Then \Prog "SUB ESIG"
4\->X:\IfEnd
\If X=63
\Then \Prog "SB ECRYP"
5\->X:\IfEnd
\If X=53
\Then \Do
"GX="?\->\r
"GY="?\->\theta
\r\->X:\theta\->Y
\Prog "SUB TSTP"
\LpWhile X\<>Y
6\->X
\IfEnd
\If X=47
\Then \Break
\IfEnd
\LpWhile 1=1
\Return
%End
%Header Record
Format:TXT
Communication SW:0
Data Type:PG
Capacity:74
File Name:TSTSIMPL
Group Name:
Password:
Option1:NL
Option2:
Option3:
Option4:
%Data Record
"INPUT NUMBER"?\->H
\Prog "SB TSIMP"
\If D=1
\Then "SIMPLE NUMBER"
\Else "NOT SIMPLE"
\Return
%End
%Header Record
Format:TXT
Communication SW:0
Data Type:PG
Capacity:652
File Name:RSA
Group Name:
Password:
Option1:NL
Option2:
Option3:
Option4:
%Data Record
\ClrText
\Do
"P="?\->P
P\->H:\Prog "SB TSIMP"
\LpWhile D\<>1
\Do
"Q="?\->Q
Q\->H:\Prog "SB TSIMP"
\LpWhile D\<>1
PQ\->N
\If P=Q
\Then P(Q-1)\->M
\Else (P-1)(Q-1)\->M
\IfEnd
"P*Q=":\Locate 8,5,N
"EILER=":\Locate 8,6,M
\Do
"INPUT OPEN KEY"?\->K
K\->X:M\->Y
\Prog "SUB NOD"
\LpWhile X\<>1
1\->A:K\->B:M\->C
\Prog "SUB DIV"
D\->L
"SECRET KEY=":L\Disp\Do
"1-ENCRYPT"
"2-DECRYPT"
"3-MAKE SIGNATURE"
"4-TEST SIGNATURE"
"OTHER - EXIT"
\Do
\Getkey\->X
\LpWhile X=0
\If X\<>72\ And X\<>62\ And X\<>52\ And X\<>73
\Then \Break
\IfEnd
\If X=72
\Then "INPUT MESSAGE"
?\->A:K\->B:N\->C
\Prog "SUB EXP"
"CRYPTOGRAM=":D\Disp0\->X:\IfEnd
\If X=62
\Then "INPUT CRYPTOGRAM"
?\->A:L\->B:N\->C
\Prog "SUB EXP"
"MESSAGE=":D\Disp0\->X:\IfEnd
\If X=52
\Then "INPUT DIJEST MSG"
?\->A:L\->B:N\->C
\Prog "SUB EXP"
"SIGNATURE=":D\Disp0\->X:\IfEnd
\If X=73
\Then "INPUT SIGNATURE":?\->A:K\->B:N\->C
\Prog "SUB EXP"
"HASH=":D\Disp0\->X:\IfEnd
\LpWhile 1=1
\Return
%End
%Header Record
Format:TXT
Communication SW:0
Data Type:PG
Capacity:385
File Name:DIFFIHEL
Group Name:
Password:
Option1:NL
Option2:
Option3:
Option4:
%Data Record
\Do
"INPUT SIMPLE"?\->P
P\->H:\Prog "SUBTSIMP"
\LpWhile D\<>1
\Do
"INPUT MANTIS"?\->M
M\->W:\Prog "SB PERVO"
\LpWhile D\<>P-1
\Do
"INPUT X1"?\->S
S\->X:P-1\->Y
\Prog "SUB NOD"
\If X\<>1
\Then "GCD(X1,P-1)\<>1"
\IfEnd
\LpWhile X\<>1
\Do
"INPUT X2"?\->T
T\->X:P-1\->Y
\Prog "SUB NOD"
\If X\<>1
\Then "GCD(X2,P-1)\<>1"
\IfEnd
\LpWhile X\<>1
M\->A:P\->C
S\->B
\Prog "SUB EXP"
D\->U
M\->A:T\->B
\Prog "SUB EXP"
D\->V
"Y1=":\Locate 4,7,U
"Y2=":\Locate 4,7,V
V\->A:S\->B
\Prog "SUB EXP":D\->W
U\->A:T\->B
\Prog "SUB EXP"
"KEY1="
\Locate 6,7,W
"KEY2="
\Locate 6,7,D

%End
%Header Record
Format:TXT
Communication SW:0
Data Type:PG
Capacity:343
File Name:LFSRALT
Group Name:
Password:
Option1:NL
Option2:
Option3:
Option4:
%Data Record
"INPUT {SEQUENCE}"?\->\List 1
\Dim \List 1\->X
\Int (X/2)\->N
{N,N+1}\->\Dim \Mat A
\For 1\->I \To N
\For 1\->J \To N+1
I+N-J\->X
\If J>N
\Then I+N\->X
\IfEnd
\List 1[X]\->\Mat A[I,J]
\Next
\Next
\Mat A\Disp\For 1\->I \To N
\If \Mat A[I,I]=0
\Then \For I+1\->J \To N
\If \Mat A[J,I]\<>0
\Then \Break
\IfEnd
\Next
\For 1\->K \To N+1
\Mat A[I,K]+\Mat A[J,K]\->X
X-2\Int (X/2)\->\Mat A[I,K]
\Next
\IfEnd
\For 1\->J \To N
\If (I\<>J)\ And \Mat A[J,I]=1
\Then \For I\->K \To N+1
\Mat A[I,K]+\Mat A[J,K]\->X
X-2\Int (X/2)\->\Mat A[J,K]
\Next
\IfEnd
\Next
\Next
\Mat A
\Stop
%End
%Header Record
Format:TXT
Communication SW:0
Data Type:PG
Capacity:462
File Name:FACTFAST
Group Name:
Password:
Option1:NL
Option2:
Option3:
Option4:
%Data Record
"INPUT NUMBER"?\->A
\While \Frac (A/2)=0
A/2\->A:2\Disp\WhileEnd
\While \Frac (A/3)=0
A/3\->A:3\Disp\WhileEnd
\While \Frac (A/5)=0
A/5\->A:5\Disp\WhileEnd
\sqrtA+1\->B
\For 7\->X \To B \Step 30
\While \Frac (A/X)=0
A/X\->A:\sqrtA+1\->B:X\Disp\WhileEnd
\While \Frac (A/(X+4))=0
A/(X+4)\->A:\sqrtA+1\->B:X+4\Disp\WhileEnd
\While \Frac (A/(X+6))=0
A/(X+6)\->A:\sqrtA+1\->B:X+6\Disp\WhileEnd
\While \Frac (A/(X+10))=0
A/(X+10)\->A:\sqrtA+1\->B:X+10\Disp\WhileEnd
\While \Frac (A/(X+12))=0
A/(X+12)\->A:\sqrtA+1\->B:X+12\Disp\WhileEnd
\While \Frac (A/(X+16))=0
A/(X+16)\->A:\sqrtA+1\->B:X+16\Disp\WhileEnd
\While \Frac (A/(X+22))=0
A/(X+22)\->A:\sqrtA+1\->B:X+22\Disp\WhileEnd
\While \Frac (A/(X+24))=0
A/(X+24)\->A:\sqrtA+1\->B:X+24\Disp\WhileEnd
\Next
\If A>1
\Then A\Disp\IfEnd
"END FACTORISATION"
\Stop
%End
%Header Record
Format:TXT
Communication SW:0
Data Type:PG
Capacity:396
File Name:RABIN
Group Name:
Password:
Option1:NL
Option2:
Option3:
Option4:
%Data Record
"INPUT P"?\->P
"INPUT Q"?\->Q
P*Q\->N
"N=":N\Disp"INPUT M"?\->M
M*M\->X
X-N\Int (X/N)\->S
"C=":S\Disp(P+1)/4\->O
S\->A:O\->B:P\->C
\Prog "SUB EXP"
D\->R
P-R\->T
(Q+1)/4\->O
O\->B:S\->A:Q\->C
\Prog "SUB EXP"
D\->U
Q-U\->V
"M1=":R\Disp"M2=":T\Disp"M3=":U\Disp"M4=":V\Disp1\->A:P\->B:Q\->C
\Prog "SUB DIV"
D*P\->L
1\->A:Q\->B:P\->C
\Prog "SUB DIV"
D*Q\->H
"A=":H\Disp"B=":L\DispH*R+L*U\->X
X-N\Int (X/N)\->X
"MM1=":X\DispH*R+L*V\->X
X-N\Int (X/N)\->X
"MM2=":X\DispH*T+L*U\->X
X-N\Int (X/N)\->X
"MM3=":X\DispH*T+L*V\->X
X-N\Int (X/N)\->X
"MM4=":X\Disp\Stop
%End
%Header Record
Format:TXT
Communication SW:0
Data Type:PG
Capacity:165
File Name:POLLARDP
Group Name:
Password:
Option1:NL
Option2:
Option3:
Option4:
%Data Record
\ClrText
"P-1 POLLARD"
"INPUT NUMBER"?\->N
\Int \In N\->B:2\->A
\For 2\->I \To B
A\->C
1\->J
\While J<I
AC-N*\Int (AC/N)\->C
J+1\->J
\WhileEnd
C\->A:A-1\->C
N\->X:C\->Y
\Next
\Prog "SUB NOD"
N/X\->Y
"ITER=":I\Disp"NUM1=":X\Disp"NUM2=":Y\Disp\Stop
%End
%Header Record
Format:TXT
Communication SW:0
Data Type:PG
Capacity:1294
File Name:EL HAMAL
Group Name:
Password:
Option1:NL
Option2:
Option3:
Option4:
%Data Record
\Do
"SIMPLE NUMBER"?\->P
P\->H:\Prog "SUBTSIMP"
\LpWhile D\<>1
\Do
"MANTIS W"?\->W
\Prog "SB PERVO"
\LpWhile D\<>P-1
\Do
"SECRET KEY X"?\->Q
Q\->X:P-1\->Y
\Prog "SUB NOD"
\If X\<>1
\Then "GCD(X,P-1)\<>1"
\IfEnd
\LpWhile X\<>1
W\->A:Q\->B:P\->C
\Prog "SUB EXP":D\->T
"OPEN KEY Y="
\Locate 12,7,T
\Do
"1-ENCRYPT"
"2-DECRYPT"
"3-MAKE SIGNATURE"
"4-TEST SIGNATURE"
"OTHER - EXIT"
\Do
\Getkey\->O
\LpWhile O=0
\If O=72
\Then "START ENCRYPTION"
\Do
"RND NUMBER K"?\->K
K\->X:P-1\->Y
\Prog "SUB NOD"
\If X\<>1
\Then "GCD(K,P-1)\<>1"
\IfEnd
\LpWhile X\<>1
T\->A:K\->B:P\->C
\Prog "SUB EXP":D\->R
"R=":\Locate 3,7,R
W\->A:K\->B:P\->C
\Prog "SUB EXP":D\->Z
"INPUT MESSAGE"?\->M
"CRYPTOGRAM"
"Z=":\Locate 3,7,Z
MR-P\Int (MR/P)\->S
"C=":\Locate 3,7,S\Disp0\->O:\IfEnd
\If O=62
\Then "INP CRYPTOGRAM (C,Z)"
"C="?\->S
"Z="?\->Z
Z\->A:Q\->B:P\->C
\Prog "SUB EXP":D\->R
1\->A:R\->B:P\->C
\Prog "SUB DIV"
S*D\->N
N-P\Int (N/P)\->N
"(1/R)="
\Locate 7,7,D
"MESSAGE="
\Locate 9,7,N\Disp0\->O:\IfEnd
\If O=52
\Then "MAKE SIGNATURE"
\Do
"RND NUMBER"?\->K
K\->X:P-1\->Y
\Prog "SUB NOD"
\If X\<>1
\Then "GCD(K,P-1)\<>1"
\IfEnd
\LpWhile X\<>1
W\->A:K\->B:P\->C
\Prog "SUB EXP":D\->R
"R=":\Locate 3,7,R
1\->A:K\->B:P-1\->C
\Prog "SUB DIV"
"1/K=":\Locate 5,7,D
"INPUT DIJEST"?\->M
QR-(P-1)\Int (QR/(P-1))\->S
M-S\->S
\If S<0
\Then S+P-1\->S
\IfEnd
DS-(P-1)\Int (DS/(P-1))\->S
"SIGNATURE"
"R=":\Locate 3,7,R
"S=":\Locate 3,7,S\Disp0\->O:\IfEnd
\If O=73
\Then "TEST SIGNATURE (R,S)"
"R="?\->R
"S="?\->S
T\->A:R\->B:P\->C
\Prog "SUB EXP":D\->U
R\->A:S\->B:P\->C
\Prog "SUB EXP":D\->V
"DIDJEST MSG"?\->M
W\->A:M\->B:P\->C
\Prog "SUB EXP"
UV-P\Int (UV/P)\->Y
\If Y=D
\Then "SIGNATURE OK"
"Y^R*R^S=W^M="
\Locate 13,7,D\Disp\Else "SIGNATURE BAD"
"Y^R*R^S="
\Locate 9,7,Y
"W^M = "
\Locate 9,7,D\Disp\IfEnd
0\->O:\IfEnd
\LpWhile O=0
\Return
%End
%Header Record
Format:TXT
Communication SW:0
Data Type:PG
Capacity:73
File Name:SUB EXP
Group Name:
Password:
Option1:NL
Option2:
Option3:
Option4:
%Data Record
1\->D:B\->E
\Do
E/2\->E
\If \Frac E>0
\Then DA-C\Int (DA/C)\->D
\IfEnd
A\x^2-C\Int (A\x^2/C)\->A
\Int E\->E
\LpWhile E\>=1
\Return
%End
%Header Record
Format:TXT
Communication SW:0
Data Type:PG
Capacity:126
File Name:SUB DIV
Group Name:
Password:
Option1:NL
Option2:
Option3:
Option4:
%Data Record
1\->D:0\->E:C\->G:B\->J:0\->I
\While J>0
\Int (B/G)\->H
B-HG\->J
\If I\<>0
\Then DH+E\->F:D\->E:F\->D
\IfEnd
G\->B:J\->G:I+1\->I
\WhileEnd
\If \Frac (I/2)\<>0
\Then C-E\->E
\IfEnd
AE-C\Int (AE/C)\->D
\Return
%End
%Header Record
Format:TXT
Communication SW:0
Data Type:PG
Capacity:38
File Name:SUB NOD
Group Name:
Password:
Option1:NL
Option2:
Option3:
Option4:
%Data Record
\While Y>0
X-Y\Int (X/Y)\->X
Y\->Z:X\->Y:Z\->X
\WhileEnd
\Return
%End
%Header Record
Format:TXT
Communication SW:0
Data Type:PG
Capacity:134
File Name:SB SETEL
Group Name:
Password:
Option1:NL
Option2:
Option3:
Option4:
%Data Record
\Do
"(Y\x^2=X^3+AX+B)MOD C"
"A"?\->K
"B"?\->L
"C"?\->C
\(-)64*K^3-432*L\x^2\->X
X-C\Int (X/C)\->X
\If X<0
\Then C+X\->X
\IfEnd
\If X=0
\Then "DISCR=0 TAKE OTHER"
\IfEnd
\LpWhile X=0
\Return
%End
%Header Record
Format:TXT
Communication SW:0
Data Type:PG
Capacity:103
File Name:SUB FNDP
Group Name:
Password:
Option1:NL
Option2:
Option3:
Option4:
%Data Record
\For 0\->X \To C
X^3+K*X+L\->Z
Z-C\Int (Z/C)\->Z
\For 0\->Y \To C
Y\x^2-C\Int (Y\x^2/C)\->\theta
\If \theta=Z
\Then \Break
\IfEnd
\Next
\If \theta=Z
\Then \Break
\IfEnd
\Next
X\->\r:Y\->\theta
\Return
%End
%Header Record
Format:TXT
Communication SW:0
Data Type:PG
Capacity:42
File Name:SUB TSTP
Group Name:
Password:
Option1:NL
Option2:
Option3:
Option4:
%Data Record
X^3+KX+L\->Z
Z-C\Int (Z/C)\->X
Y\x^2-C\Int (Y\x^2/C)\->Y
\Return
%End
%Header Record
Format:TXT
Communication SW:0
Data Type:PG
Capacity:205
File Name:SUB ADDP
Group Name:
Password:
Option1:NL
Option2:
Option3:
Option4:
%Data Record
\Do
"INP POINT 1"
"X="?\->\List 6[1]
"Y="?\->\List 6[2]
\List 6[1]\->X
\List 6[2]\->Y
\Prog "SUB TSTP"
\LpWhile X\<>Y
\Do
"INP POINT 2"
"X="?\->\List 6[3]
"Y="?\->\List 6[4]
\List 6[3]\->X
\List 6[4]\->Y
\Prog "SUB TSTP"
\LpWhile X\<>Y
\Prog "SUB ADPT"
\List 6[5]\->X
\List 6[6]\->Y
\Prog "SB SHOWP"
\Return
%End
%Header Record
Format:TXT
Communication SW:0
Data Type:PG
Capacity:70
File Name:SB SHOWP
Group Name:
Password:
Option1:NL
Option2:
Option3:
Option4:
%Data Record
\If X=C\ And Y=C
\Then "ZERO POINT"\Disp\Else "X="
\Locate 3,7,X
\Locate 11,7,"Y="
\Locate 13,7,Y\Disp\IfEnd
\Return
%End
%Header Record
Format:TXT
Communication SW:0
Data Type:PG
Capacity:631
File Name:SUB ADPT
Group Name:
Password:
Option1:NL
Option2:
Option3:
Option4:
%Data Record
\If \List 6[1]=C\ And \List 6[2]=C
\Then \List 6[3]\->\List 6[5]
\List 6[4]\->\List 6[6]
\Return
\IfEnd
\If \List 6[3]=C\ And \List 6[4]=C
\Then \List 6[1]\->\List 6[5]
\List 6[2]\->\List 6[6]
\Return
\IfEnd
\If \List 6[1]=\List 6[3]\ And \List 6[2]=C-\List 6[4]
\Then C\->\List 6[5]
C\->\List 6[6]
\Return
\IfEnd
\If \List 6[1]=\List 6[3]\ And \List 6[2]\<>C-\List 6[4]
\Then 3\List 6[1]\x^2+K\->X
X-C\Int (X/C)\->A
2\List 6[2]-C\Int (2\List 6[2]/C)\->B
\Prog "SUB DIV"
D\->U
\List 6[1]\x^2\->X
\List 6[1](X-C\Int (X/C))\->X
C-(X-C\Int (X/C))\->X
X+K\List 6[1]+2L\->X
X-C\Int (X/C)\->A
2\List 6[2]-C\Int (2\List 6[2]/C)\->B
\Prog "SUB DIV"
D\->V
\Else \List 6[4]-\List 6[2]+C\->X
X-C\Int (X/C)\->A
\List 6[3]-\List 6[1]+C\->X
X-C\Int (X/C)\->B:B\->W
\Prog "SUB DIV":D\->U
\List 6[2]*\List 6[3]-\List 6[1]*\List 6[4]\->X
X-C\Int (X/C)+C\->X
X-C\Int (X/C)\->A
W\->B
\Prog "SUB DIV":D\->V
\IfEnd
U\x^2+2C-\List 6[1]-\List 6[3]\->X
X-C\Int (X/C)\->\List 6[5]
\(-)U\List 6[5]-V\->X
X-C\Int (X/C)+C\->X
X-C\Int (X/C)\->\List 6[6]
\Return
%End
%Header Record
Format:TXT
Communication SW:0
Data Type:PG
Capacity:139
File Name:SUB MULP
Group Name:
Password:
Option1:NL
Option2:
Option3:
Option4:
%Data Record
\Do
"INPUT POINT"
"X="?\->X
X\->\List 6[7]
"Y="?\->Y
Y\->\List 6[8]
\Prog "SUB TSTP"
\LpWhile X\<>Y
"INPUT MULTIPLIER"?\->Z
\Prog "SB MULPT"
\List 6[9]\->X
\List 6[10]\->Y
\Prog "SB SHOWP"
\Return
%End
%Header Record
Format:TXT
Communication SW:0
Data Type:PG
Capacity:252
File Name:SB MULPT
Group Name:
Password:
Option1:NL
Option2:
Option3:
Option4:
%Data Record
C\->\List 6[9]
C\->\List 6[10]
\While Z\<>0
\If \Frac (Z/2)>0
\Then \List 6[9]\->\List 6[1]
\List 6[10]\->\List 6[2]
\List 6[7]\->\List 6[3]
\List 6[8]\->\List 6[4]
\Prog "SUB ADPT"
\List 6[5]\->\List 6[9]
\List 6[6]\->\List 6[10]
\IfEnd
\List 6[7]\->\List 6[1]
\List 6[8]\->\List 6[2]
\List 6[7]\->\List 6[3]
\List 6[8]\->\List 6[4]
\Prog "SUB ADPT"
\List 6[5]\->\List 6[7]
\List 6[6]\->\List 6[8]
\Int (Z/2)\->Z
\WhileEnd
\Return
%End
%Header Record
Format:TXT
Communication SW:0
Data Type:PG
Capacity:494
File Name:SUBMKKEY
Group Name:
Password:
Option1:NL
Option2:
Option3:
Option4:
%Data Record
"INP SEC PARAMETER"
"X1="?\->\List 6[11]
"X2="?\->\List 6[12]
"MESSAGE SUBSCR 1"
\r\->\List 6[7]
\theta\->\List 6[8]
\List 6[11]\->Z
\Prog "SB MULPT"
\List 6[9]\->\List 6[13]
\List 6[10]\->\List 6[14]
\List 6[9]\->X
\List 6[10]\->Y
\Prog "SB SHOWP"
"MESSAGE SUBSCR 2"
\r\->\List 6[7]
\theta\->\List 6[8]
\List 6[12]\->Z
\Prog "SB MULPT"
\List 6[9]\->\List 6[15]
\List 6[10]\->\List 6[16]
\List 6[15]\->X
\List 6[16]\->Y
\Prog "SB SHOWP"
"KEY SUBSCR 1"
\List 6[11]\->Z
\List 6[15]\->\List 6[7]
\List 6[16]\->\List 6[8]
\Prog "SB MULPT"
\List 6[9]\->X
\List 6[10]\->Y
\Prog "SB SHOWP"
"KEY SUBSCR 2"
\List 6[12]\->Z
\List 6[13]\->\List 6[7]
\List 6[14]\->\List 6[8]
\Prog "SB MULPT"
\List 6[9]\->X
\List 6[10]\->Y
\Prog "SB SHOWP"
\Return
%End
%Header Record
Format:TXT
Communication SW:0
Data Type:PG
Capacity:1460
File Name:SUB ESIG
Group Name:
Password:
Option1:NL
Option2:
Option3:
Option4:
%Data Record
"WAIT PLEASE..."
\r\->M:\theta\->N:1\->O
\Do
O+1\->O
M\->\List 6[1]
N\->\List 6[2]
\r\->\List 6[3]
\theta\->\List 6[4]
\Prog "SUB ADPT"
\List 6[5]\->M
\List 6[6]\->N
\LpWhile M\<>C\ And N\<>C
O\->A
\Prog "SUB FACT"
D\->\List 6[12]
"INP SECR KEY D<"
\Locate 16,7,D
?\->\List 6[11]
O/D\->Z
\r\->\List 6[7]
\theta\->\List 6[8]
\Prog "SB MULPT"
\List 6[9]\->\List 6[13]
\List 6[10]\->\List 6[14]
\List 6[11]\->Z
\List 6[13]\->\List 6[7]
\List 6[14]\->\List 6[8]
\Prog "SB MULPT"
\List 6[9]\->\List 6[15]
\List 6[10]\->\List 6[16]
"OPEN KEY (N,Z,Q)"
"N (POITNTS)="
\Locate 13,7,\List 6[12]
"POINT Z"
\List 6[13]\->X
\List 6[14]\->Y
\Prog "SB SHOWP"
"POINT Q"
\List 6[15]\->X
\List 6[16]\->Y
\Prog "SB SHOWP"
"MAKE SIGNATURE"
\Do
"INP ANY NUMBER K<N"?\->\List 6[17]
"INPUT HASH MESSAGE"?\->\List 6[18]
\List 6[13]\->\List 6[7]
\List 6[14]\->\List 6[8]
\List 6[17]\->Z
\Prog "SB MULPT"
\List 6[9]\->\List 6[19]
\List 6[10]\->\List 6[20]
"POINT (X1,Y1)"
\List 6[19]\->X
\List 6[20]\->Y
\Prog "SB SHOWP"
\List 6[19]\->X
\List 6[12]\->Y
X-Y\Int (X/Y)\->X
X\->\List 6[21]
C\->W:\List 6[12]\->C
1\->A:\List 6[17]\->B
\Prog "SUB DIV"
W\->C
\List 6[18]+\List 6[11]*\List 6[21]\->X
\List 6[12]\->Y
X-Y\Int (X/Y)\->X
XD\->X
X-Y\Int (X/Y)\->X
X\->\List 6[22]
\If X=0
\Then "SIGNATURE=0 CHANGE K"
\IfEnd
\LpWhile X=0
"SIGNATURE"
"R ="
\Locate 5,7,\List 6[21]
"S ="
\Locate 5,7,\List 6[22]\Disp"SIGNATURE TEST"
1\->A:C\->W
\List 6[22]\->B
\List 6[12]\->C
\Prog "SUB DIV"
W\->C:\List 6[12]\->Y
D\->\List 6[27]
D\List 6[18]\->X
X-Y\Int (X/Y)\->\List 6[23]
D\List 6[21]\->X
X-Y\Int (X/Y)\->\List 6[24]
"W ="
\Locate 5,7,D
"U1="
\Locate 5,7,\List 6[23]
"U2="
\Locate 5,7,\List 6[24]
\List 6[23]\->Z
\List 6[13]\->\List 6[7]
\List 6[14]\->\List 6[8]
\Prog "SB MULPT"
\List 6[9]\->P
\List 6[10]\->Q
\List 6[24]\->Z
\List 6[15]\->\List 6[7]
\List 6[16]\->\List 6[8]
\Prog "SB MULPT"
\List 6[9]\->\List 6[1]
\List 6[10]\->\List 6[2]
P\->\List 6[3]
Q\->\List 6[4]
\Prog "SUB ADPT"
\List 6[5]\->X
X\->\List 6[25]
\List 6[6]\->Y
Y\->\List 6[26]
"POINT X0"
\Prog "SB SHOWP"
\List 6[12]\->Y
X-Y\Int (X/Y)\->X
X\->\List 6[28]
"V ="
\Locate 5,7,X
\If X=\List 6[21]
\Then "SIGNATURE OK"\Disp\Else "SIGNATURE BAD"\Disp\IfEnd
\Return
%End
%Header Record
Format:TXT
Communication SW:0
Data Type:PG
Capacity:147
File Name:SUB FACT
Group Name:
Password:
Option1:NL
Option2:
Option3:
Option4:
%Data Record
A\->D
\While \Frac (A/2)=0
A/2\->A:2\->D
\WhileEnd
\While \Frac (A/3)=0
A/3\->A:3\->D
\WhileEnd
\sqrtA+1\->B
\For 5\->X \To B \Step 6
\While \Frac (A/X)=0
X\->D:A/D\->A:\sqrtA+1\->B
\WhileEnd
\While \Frac (A/(X+2))=0
X+2\->D:A/D\->A:\sqrtA+1\->B
\WhileEnd
\Next
\Return
%End
%Header Record
Format:TXT
Communication SW:0
Data Type:PG
Capacity:72
File Name:SB TSIMP
Group Name:
Password:
Option1:NL
Option2:
Option3:
Option4:
%Data Record
2\->F:\In H\->G
\For 1\->I \To G
F\->A:H-1\->B:H\->C
\Prog "SUB EXP"
\If D\<>1
\Then \Break
\IfEnd
2F+1\->F
\Next
\Return
%End
%Header Record
Format:TXT
Communication SW:0
Data Type:PG
Capacity:811
File Name:SB ECRYP
Group Name:
Password:
Option1:NL
Option2:
Option3:
Option4:
%Data Record
"INPUT SEC KEY NB"?\->Z:Z\->\List 6[11]
\r\->\List 6[7]
\theta\->\List 6[8]
\Prog "SB MULPT"
\List 6[9]\->X
\List 6[10]\->Y
X\->\List 6[13]
Y\->\List 6[14]
"OPEN KEY PB"
\Prog "SB SHOWP"
"INPUT MESSAGE M"?\->Z:Z\->\List 6[12]
\List 6[13]\->\List 6[7]
\List 6[14]\->\List 6[8]
\Prog "SB MULPT"
\List 6[9]\->X
\List 6[10]\->Y
X\->\List 6[15]
Y\->\List 6[16]
"POINT PM"
\Prog "SB SHOWP"
"INP ANY NUMBER K"?\->Z:Z\->\List 6[23]
\r\->\List 6[7]
\theta\->\List 6[8]
\Prog "SB MULPT"
\List 6[9]\->X
\List 6[10]\->Y
X\->\List 6[17]
Y\->\List 6[18]
"CRYPTOGRAM C1,C2"
"POINT C1"
\Prog "SB SHOWP"
\List 6[23]\->Z
\List 6[13]\->\List 6[7]
\List 6[14]\->\List 6[8]
\Prog "SB MULPT"
\List 6[9]\->\List 6[1]
\List 6[10]\->\List 6[2]
\List 6[15]\->\List 6[3]
\List 6[16]\->\List 6[4]
\Prog "SUB ADPT"
\List 6[5]\->X
\List 6[6]\->Y
X\->\List 6[19]
Y\->\List 6[20]
"POINT C2"
\Prog "SB SHOWP"
\List 6[11]\->Z
\List 6[17]\->\List 6[7]
\List 6[18]\->\List 6[8]
\Prog "SB MULPT"
\List 6[9]\->\List 6[1]
\(-)\List 6[10]\->\List 6[2]
\List 6[19]\->\List 6[3]
\List 6[20]\->\List 6[4]
\Prog "SUB ADPT"
\List 6[5]\->X
\List 6[6]\->Y
X\->\List 6[21]
Y\->\List 6[22]
"DECRYPTED PM"
\Prog "SB SHOWP"
"DECRYPTED MESSAGE"
\List 6[12]\Disp\Return
%End
%Header Record
Format:TXT
Communication SW:0
Data Type:PG
Capacity:97
File Name:SUBTSIMP
Group Name:
Password:
Option1:NL
Option2:
Option3:
Option4:
%Data Record
H\->X
\Prog "SB TSIMP"
\If D=1
\Then (X-1)/2\->H
\Prog "SB TSIMP"
\If D\<>1
\Then "LOW PROTECTION"
\IfEnd
\Else "NOT SIMPLE"
\IfEnd
\Return
%End
%Header Record
Format:TXT
Communication SW:0
Data Type:PG
Capacity:114
File Name:SB PERVO
Group Name:
Password:
Option1:NL
Option2:
Option3:
Option4:
%Data Record
(P-1)/2\->H
\Prog "SB TSIMP"
\If D=1
\Then P\->C
(P-1)/2\->B
W\->A
\Prog "SUB EXP"
\If D\<>P-1
\Then "NOT PERVOOBR"
\IfEnd
\Else "LOW PROTECTION"
\IfEnd
\Return
%End

blog comments powered by Disqus