Difference between revisions of "83Plus:BCALLs:80A2"

From WikiTI
Jump to: navigation, search
 
(Example)
 
(13 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[Category:83Plus:BCALLs:By Name:Math|Rabin]]
+
[[Category:83Plus:BCALLs:By Name:Cryptography|SigModR]] [[Category:83Plus:BCALLs:By Name:Math:Big Integer|SigModR]] [[Category:83Plus:BCALLs:By Name:Math|SigModR]] [[Category:83Plus:BCALLs:By Name|SigModR]] [[Category:83Plus:BCALLs:By Address|80A2 - SigModR]]
[[Category:83Plus:BCALLs:By Name|Rabin]]
+
[[Category:83Plus:BCALLs:By Address|80A2 - Rabin]]
+
 
== Synopsis ==
 
== Synopsis ==
'''Official Name:''' Rabin
+
'''Official Name:''' SigModR
 +
 
 +
'''Other Name:''' Rabin
  
 
'''BCALL Address:''' 80A2
 
'''BCALL Address:''' 80A2
Line 10: Line 10:
  
 
=== Inputs ===
 
=== Inputs ===
* HL = ciphertext
+
* HL points to the signature, a [[83Plus:OS:Big_Integers|big integer]]
* 8000h = modulus n of the public key
+
* [[83Plus:RAM:8000|8000]] holds the modulus, another big integer
  
 
=== Outputs ===
 
=== Outputs ===
* 8100h = plaintext
+
* [[83Plus:RAM:8478|OP1-OP6]] hold the plaintext, a big integer
  
 
=== Destroys ===
 
=== Destroys ===
* hardware registers?
+
* All registers
* 8100h (large int result register)
+
* [[83Plus:RAM:8100|8100h]]: 130-byte area which the multiplication routine uses to store its result
* 8182h (large int operand 1)
+
* [[83Plus:RAM:8182|8182h]]: 65-byte area used as the first argument to the multiplication routine
* 81C3h (large int operand 2)
+
* [[83Plus:RAM:81C3|81C3h]]: 65-byte area used as the second argument to the multiplication routine
  
 
== Comments ==
 
== Comments ==
Line 26: Line 26:
  
 
== Example ==
 
== Example ==
   B_CALL GetFreewareKey ;loads the modulus into 8000h
+
   B_CALL [[83Plus:BCALLs:809F|SetupAppPubKey]] ;loads the modulus into 8000h
   ld    de,tempSwapArea
+
   ld    de,[[83Plus:RAM:82A5|tempSwapArea]]
 
   push  de
 
   push  de
 
   ld    hl,myInt
 
   ld    hl,myInt
Line 33: Line 33:
 
   ldir                  ;copy large int to RAM
 
   ldir                  ;copy large int to RAM
 
   pop    hl              ;address of large int to square
 
   pop    hl              ;address of large int to square
   B_CALL Rabin          ;square it
+
   B_CALL SigModR        ;square it
 
   ;8100h should now contain the number 3412h^2 mod the 0104 key.   
 
   ;8100h should now contain the number 3412h^2 mod the 0104 key.   
 
   ;Since the n of the public key is significantly larger, the answer is simply
 
   ;Since the n of the public key is significantly larger, the answer is simply
Line 39: Line 39:
 
   ;8100h: 04 44 51 97 0A
 
   ;8100h: 04 44 51 97 0A
 
   ;(the integer A975144h)
 
   ;(the integer A975144h)
 
+
myInt:
myInt:
+
 
   db  2,12h,34h
 
   db  2,12h,34h
myIntEnd:
+
myIntEnd:

Latest revision as of 09:57, 30 March 2005

Synopsis

Official Name: SigModR

Other Name: Rabin

BCALL Address: 80A2

Squares a large integer modulo n.

Inputs

  • HL points to the signature, a big integer
  • 8000 holds the modulus, another big integer

Outputs

  • OP1-OP6 hold the plaintext, a big integer

Destroys

  • All registers
  • 8100h: 130-byte area which the multiplication routine uses to store its result
  • 8182h: 65-byte area used as the first argument to the multiplication routine
  • 81C3h: 65-byte area used as the second argument to the multiplication routine

Comments

This BCALL takes a large integer pointed to by HL and squares it modulo n. The OS uses this to decrypt the Rabin encrypted MD5 hash of an app.

Example

 B_CALL SetupAppPubKey  ;loads the modulus into 8000h
 ld     de,tempSwapArea
 push   de
 ld     hl,myInt
 ld     bc,myIntEnd-myInt
 ldir                   ;copy large int to RAM
 pop    hl              ;address of large int to square
 B_CALL SigModR         ;square it
 ;8100h should now contain the number 3412h^2 mod the 0104 key.  
 ;Since the n of the public key is significantly larger, the answer is simply
 ;3412h^2.  So the contents of memory after this BCALL are
 ;8100h: 04 44 51 97 0A
 ;(the integer A975144h)
myInt:
 db  2,12h,34h
myIntEnd: