Difference between revisions of "83Plus:BCALLs:80A2"
From WikiTI
(→Example) |
(→Example) |
||
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: |
Revision as of 22:59, 28 March 2005
Synopsis
Official Name: Rabin
BCALL Address: 80A2
Squares a large integer modulo n.
Inputs
- HL = ciphertext
- 8000h = modulus n of the public key
Outputs
- 8100h = plaintext
Destroys
- hardware registers?
- 8100h (large int result register)
- 8182h (large int operand 1)
- 81C3h (large int operand 2)
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 GetFreewareKey ;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 Rabin ;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: