Subversion Repositories Kolibri OS

Rev

Rev 9114 | Rev 9216 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9114 Rev 9126
Line 126... Line 126...
126
        EM                      dd ?
126
        EM                      dd ?
127
        EM_accent               dd ?
127
        EM_accent               dd ?
Line 128... Line 128...
128
 
128
 
Line 129... Line -...
129
        mpint_s                 dd ?    ; rsa_signature_blob
-
 
130
 
129
        mpint_s                 dd ?    ; rsa_signature_blob
Line 131... Line 130...
131
 
130
 
Line 132... Line 131...
132
;        k       dd ?    ; length of RSA modulus n
131
        k                       dd ?    ; Key length
Line 171... Line 170...
171
        stdcall mpint_to_little_endian, [mpint_e], esi
170
        stdcall mpint_to_little_endian, [mpint_e], esi
172
        add     esi, eax
171
        add     esi, eax
173
        add     esi, 4
172
        add     esi, 4
174
; mpint n
173
; mpint n
175
        stdcall mpint_to_little_endian, [mpint_n], esi
174
        stdcall mpint_to_little_endian, [mpint_n], esi
176
;        mov     [k], eax             ;; HMMMM FIXME, 0-byte..
175
        and     eax, not (32-1)         ; CHECKME
-
 
176
        mov     [k], eax
Line 177... Line 177...
177
 
177
 
178
; Signature
178
; Signature
179
        mov     esi, [str_signature]
179
        mov     esi, [str_signature]
180
        mov     ecx, [esi]
180
        mov     ecx, [esi]
Line 216... Line 216...
216
        mov     edi, [EM_accent]
216
        mov     edi, [EM_accent]
217
        mov     al, 0x00
217
        mov     al, 0x00
218
        stosb
218
        stosb
219
        mov     al, 0x01
219
        mov     al, 0x01
220
        stosb
220
        stosb
-
 
221
        mov     ecx, [k]
221
        mov     ecx, 256 - (rsa_sha1_T.len + 3 + SHA1_HASH_SIZE)
222
        sub     ecx, (rsa_sha1_T.len + 3 + SHA1_HASH_SIZE)
-
 
223
        jl      .err_key
-
 
224
        jz      @f
222
        mov     al, 0xff
225
        mov     al, 0xff
223
        rep stosb
226
        rep stosb
-
 
227
  @@:
224
        mov     al, 0x00
228
        mov     al, 0x00
225
        stosb
229
        stosb
226
        mov     esi, rsa_sha1_T
230
        mov     esi, rsa_sha1_T
227
        mov     ecx, rsa_sha1_T.len
231
        mov     ecx, rsa_sha1_T.len
228
        rep movsb
232
        rep movsb
Line 246... Line 250...
246
        mov     edi, [EM_accent]
250
        mov     edi, [EM_accent]
247
        mov     al, 0x00
251
        mov     al, 0x00
248
        stosb
252
        stosb
249
        mov     al, 0x01
253
        mov     al, 0x01
250
        stosb
254
        stosb
-
 
255
        mov     ecx, [k]
251
        mov     ecx, 256 - (rsa_sha256_T.len + 3 + SHA256_HASH_SIZE)
256
        sub     ecx, (rsa_sha256_T.len + 3 + SHA256_HASH_SIZE)
-
 
257
        jl      .err_key
-
 
258
        jz      @f
252
        mov     al, 0xff
259
        mov     al, 0xff
253
        rep stosb
260
        rep stosb
-
 
261
  @@:
254
        mov     al, 0x00
262
        mov     al, 0x00
255
        stosb
263
        stosb
256
        mov     esi, rsa_sha256_T
264
        mov     esi, rsa_sha256_T
257
        mov     ecx, rsa_sha256_T.len
265
        mov     ecx, rsa_sha256_T.len
258
        rep movsb
266
        rep movsb
Line 276... Line 284...
276
        mov     edi, [EM_accent]
284
        mov     edi, [EM_accent]
277
        mov     al, 0x00
285
        mov     al, 0x00
278
        stosb
286
        stosb
279
        mov     al, 0x01
287
        mov     al, 0x01
280
        stosb
288
        stosb
-
 
289
        mov     ecx, [k]
281
        mov     ecx, 256 - (rsa_sha512_T.len + 3 + SHA512_HASH_SIZE)
290
        sub     ecx, (rsa_sha512_T.len + 3 + SHA512_HASH_SIZE)
-
 
291
        jl      .err_key
-
 
292
        jz      @f
282
        mov     al, 0xff
293
        mov     al, 0xff
283
        rep stosb
294
        rep stosb
-
 
295
  @@:
284
        mov     al, 0x00
296
        mov     al, 0x00
285
        stosb
297
        stosb
286
        mov     esi, rsa_sha512_T
298
        mov     esi, rsa_sha512_T
287
        mov     ecx, rsa_sha512_T.len
299
        mov     ecx, rsa_sha512_T.len
288
        rep movsb
300
        rep movsb
Line 295... Line 307...
295
 
307
 
296
  .rsa:
308
  .rsa:
297
; RSA signature blob
309
; RSA signature blob
298
        stdcall mpint_to_little_endian, [mpint_s], esi
310
        stdcall mpint_to_little_endian, [mpint_s], esi
299
;        cmp     eax, [k]
311
;        cmp     eax, [k]
Line 300... Line 312...
300
 ;;;       jne     .err_signature
312
;        jne     .err_signature
301
 
313
 
302
; RSAVP1
314
; RSAVP1
303
        stdcall mpint_modexp, [mpint_m], [mpint_s], [mpint_e], [mpint_n]
315
        stdcall mpint_modexp, [mpint_m], [mpint_s], [mpint_e], [mpint_n]
304
; I2OSP
316
; I2OSP
305
        stdcall mpint_shrink, [mpint_m]
317
        stdcall mpint_shrink, [mpint_m]
Line 306... Line 318...
306
        stdcall mpint_grow, [mpint_m], 256
318
        stdcall mpint_grow, [mpint_m], [k]
307
        stdcall mpint_to_big_endian, [EM], [mpint_m]
319
        stdcall mpint_to_big_endian, [EM], [mpint_m]
308
 
320
 
309
; Compare EM with EM_accent
321
; Compare EM with EM_accent
310
        mov     esi, [EM]
322
        mov     esi, [EM]
-
 
323
        add     esi, 4
311
        add     esi, 4
324
        mov     edi, [EM_accent]
312
        mov     edi, [EM_accent]
325
        mov     ecx, [k]
313
        mov     ecx, 256/4
326
        shr     ecx, 2
314
        xor     eax, eax
327
        xor     eax, eax
315
  .ct_cmp_loop:
328
  .ct_cmp_loop: