61
61
#define BLFRND (s ,p ,i ,j ,n ) (i ^= F(s,j) ^ (p)[n])
62
62
63
63
void
64
- Blowfish_encipher (blf_ctx * c , u_int32_t * x )
64
+ Vapor_Blowfish_encipher (blf_ctx * c , u_int32_t * x )
65
65
{
66
66
u_int32_t Xl ;
67
67
u_int32_t Xr ;
@@ -86,7 +86,7 @@ Blowfish_encipher(blf_ctx *c, u_int32_t *x)
86
86
}
87
87
88
88
void
89
- Blowfish_decipher (blf_ctx * c , u_int32_t * x )
89
+ Vapor_Blowfish_decipher (blf_ctx * c , u_int32_t * x )
90
90
{
91
91
u_int32_t Xl ;
92
92
u_int32_t Xr ;
@@ -111,7 +111,7 @@ Blowfish_decipher(blf_ctx *c, u_int32_t *x)
111
111
}
112
112
113
113
void
114
- Blowfish_initstate (blf_ctx * c )
114
+ Vapor_Blowfish_initstate (blf_ctx * c )
115
115
{
116
116
/* P-box and S-box tables initialized with digits of Pi */
117
117
@@ -391,8 +391,8 @@ Blowfish_initstate(blf_ctx *c)
391
391
}
392
392
393
393
u_int32_t
394
- Blowfish_stream2word (const u_int8_t * data , u_int16_t databytes ,
395
- u_int16_t * current )
394
+ Vapor_Blowfish_stream2word (const u_int8_t * data , u_int16_t databytes ,
395
+ u_int16_t * current )
396
396
{
397
397
u_int8_t i ;
398
398
u_int16_t j ;
@@ -412,7 +412,7 @@ Blowfish_stream2word(const u_int8_t *data, u_int16_t databytes,
412
412
}
413
413
414
414
void
415
- Blowfish_expand0state (blf_ctx * c , const u_int8_t * key , u_int16_t keybytes )
415
+ Vapor_Blowfish_expand0state (blf_ctx * c , const u_int8_t * key , u_int16_t keybytes )
416
416
{
417
417
u_int16_t i ;
418
418
u_int16_t j ;
@@ -423,23 +423,23 @@ Blowfish_expand0state(blf_ctx *c, const u_int8_t *key, u_int16_t keybytes)
423
423
j = 0 ;
424
424
for (i = 0 ; i < BLF_N + 2 ; i ++ ) {
425
425
/* Extract 4 int8 to 1 int32 from keystream */
426
- temp = Blowfish_stream2word (key , keybytes , & j );
426
+ temp = Vapor_Blowfish_stream2word (key , keybytes , & j );
427
427
c -> P [i ] = c -> P [i ] ^ temp ;
428
428
}
429
429
430
430
j = 0 ;
431
431
data [0 ] = 0x00000000 ;
432
432
data [1 ] = 0x00000000 ;
433
433
for (i = 0 ; i < BLF_N + 2 ; i += 2 ) {
434
- Blowfish_encipher (c , data );
434
+ Vapor_Blowfish_encipher (c , data );
435
435
436
436
c -> P [i ] = data [0 ];
437
437
c -> P [i + 1 ] = data [1 ];
438
438
}
439
439
440
440
for (i = 0 ; i < 4 ; i ++ ) {
441
441
for (k = 0 ; k < 256 ; k += 2 ) {
442
- Blowfish_encipher (c , data );
442
+ Vapor_Blowfish_encipher (c , data );
443
443
444
444
c -> S [i ][k ] = data [0 ];
445
445
c -> S [i ][k + 1 ] = data [1 ];
@@ -449,8 +449,8 @@ Blowfish_expand0state(blf_ctx *c, const u_int8_t *key, u_int16_t keybytes)
449
449
450
450
451
451
void
452
- Blowfish_expandstate (blf_ctx * c , const u_int8_t * data , u_int16_t databytes ,
453
- const u_int8_t * key , u_int16_t keybytes )
452
+ Vapor_Blowfish_expandstate (blf_ctx * c , const u_int8_t * data , u_int16_t databytes ,
453
+ const u_int8_t * key , u_int16_t keybytes )
454
454
{
455
455
u_int16_t i ;
456
456
u_int16_t j ;
@@ -461,27 +461,27 @@ Blowfish_expandstate(blf_ctx *c, const u_int8_t *data, u_int16_t databytes,
461
461
j = 0 ;
462
462
for (i = 0 ; i < BLF_N + 2 ; i ++ ) {
463
463
/* Extract 4 int8 to 1 int32 from keystream */
464
- temp = Blowfish_stream2word (key , keybytes , & j );
464
+ temp = Vapor_Blowfish_stream2word (key , keybytes , & j );
465
465
c -> P [i ] = c -> P [i ] ^ temp ;
466
466
}
467
467
468
468
j = 0 ;
469
469
d [0 ] = 0x00000000 ;
470
470
d [1 ] = 0x00000000 ;
471
471
for (i = 0 ; i < BLF_N + 2 ; i += 2 ) {
472
- d [0 ] ^= Blowfish_stream2word (data , databytes , & j );
473
- d [1 ] ^= Blowfish_stream2word (data , databytes , & j );
474
- Blowfish_encipher (c , d );
472
+ d [0 ] ^= Vapor_Blowfish_stream2word (data , databytes , & j );
473
+ d [1 ] ^= Vapor_Blowfish_stream2word (data , databytes , & j );
474
+ Vapor_Blowfish_encipher (c , d );
475
475
476
476
c -> P [i ] = d [0 ];
477
477
c -> P [i + 1 ] = d [1 ];
478
478
}
479
479
480
480
for (i = 0 ; i < 4 ; i ++ ) {
481
481
for (k = 0 ; k < 256 ; k += 2 ) {
482
- d [0 ]^= Blowfish_stream2word (data , databytes , & j );
483
- d [1 ] ^= Blowfish_stream2word (data , databytes , & j );
484
- Blowfish_encipher (c , d );
482
+ d [0 ] ^= Vapor_Blowfish_stream2word (data , databytes , & j );
483
+ d [1 ] ^= Vapor_Blowfish_stream2word (data , databytes , & j );
484
+ Vapor_Blowfish_encipher (c , d );
485
485
486
486
c -> S [i ][k ] = d [0 ];
487
487
c -> S [i ][k + 1 ] = d [1 ];
@@ -491,43 +491,43 @@ Blowfish_expandstate(blf_ctx *c, const u_int8_t *data, u_int16_t databytes,
491
491
}
492
492
493
493
void
494
- blf_key (blf_ctx * c , const u_int8_t * k , u_int16_t len )
494
+ vapor_blf_key (blf_ctx * c , const u_int8_t * k , u_int16_t len )
495
495
{
496
496
/* Initialize S-boxes and subkeys with Pi */
497
- Blowfish_initstate (c );
497
+ Vapor_Blowfish_initstate (c );
498
498
499
499
/* Transform S-boxes and subkeys with key */
500
- Blowfish_expand0state (c , k , len );
500
+ Vapor_Blowfish_expand0state (c , k , len );
501
501
}
502
502
503
503
void
504
- blf_enc (blf_ctx * c , u_int32_t * data , u_int16_t blocks )
504
+ vapor_blf_enc (blf_ctx * c , u_int32_t * data , u_int16_t blocks )
505
505
{
506
506
u_int32_t * d ;
507
507
u_int16_t i ;
508
508
509
509
d = data ;
510
510
for (i = 0 ; i < blocks ; i ++ ) {
511
- Blowfish_encipher (c , d );
511
+ Vapor_Blowfish_encipher (c , d );
512
512
d += 2 ;
513
513
}
514
514
}
515
515
516
516
void
517
- blf_dec (blf_ctx * c , u_int32_t * data , u_int16_t blocks )
517
+ vapor_blf_dec (blf_ctx * c , u_int32_t * data , u_int16_t blocks )
518
518
{
519
519
u_int32_t * d ;
520
520
u_int16_t i ;
521
521
522
522
d = data ;
523
523
for (i = 0 ; i < blocks ; i ++ ) {
524
- Blowfish_decipher (c , d );
524
+ Vapor_Blowfish_decipher (c , d );
525
525
d += 2 ;
526
526
}
527
527
}
528
528
529
529
void
530
- blf_ecb_encrypt (blf_ctx * c , u_int8_t * data , u_int32_t len )
530
+ vapor_blf_ecb_encrypt (blf_ctx * c , u_int8_t * data , u_int32_t len )
531
531
{
532
532
u_int32_t l , r , d [2 ];
533
533
u_int32_t i ;
@@ -537,7 +537,7 @@ blf_ecb_encrypt(blf_ctx *c, u_int8_t *data, u_int32_t len)
537
537
r = data [4 ] << 24 | data [5 ] << 16 | data [6 ] << 8 | data [7 ];
538
538
d [0 ] = l ;
539
539
d [1 ] = r ;
540
- Blowfish_encipher (c , d );
540
+ Vapor_Blowfish_encipher (c , d );
541
541
l = d [0 ];
542
542
r = d [1 ];
543
543
data [0 ] = l >> 24 & 0xff ;
@@ -553,7 +553,7 @@ blf_ecb_encrypt(blf_ctx *c, u_int8_t *data, u_int32_t len)
553
553
}
554
554
555
555
void
556
- blf_ecb_decrypt (blf_ctx * c , u_int8_t * data , u_int32_t len )
556
+ vapor_blf_ecb_decrypt (blf_ctx * c , u_int8_t * data , u_int32_t len )
557
557
{
558
558
u_int32_t l , r , d [2 ];
559
559
u_int32_t i ;
@@ -563,7 +563,7 @@ blf_ecb_decrypt(blf_ctx *c, u_int8_t *data, u_int32_t len)
563
563
r = data [4 ] << 24 | data [5 ] << 16 | data [6 ] << 8 | data [7 ];
564
564
d [0 ] = l ;
565
565
d [1 ] = r ;
566
- Blowfish_decipher (c , d );
566
+ Vapor_Blowfish_decipher (c , d );
567
567
l = d [0 ];
568
568
r = d [1 ];
569
569
data [0 ] = l >> 24 & 0xff ;
@@ -579,7 +579,7 @@ blf_ecb_decrypt(blf_ctx *c, u_int8_t *data, u_int32_t len)
579
579
}
580
580
581
581
void
582
- blf_cbc_encrypt (blf_ctx * c , u_int8_t * iv , u_int8_t * data , u_int32_t len )
582
+ vapor_blf_cbc_encrypt (blf_ctx * c , u_int8_t * iv , u_int8_t * data , u_int32_t len )
583
583
{
584
584
u_int32_t l , r , d [2 ];
585
585
u_int32_t i , j ;
@@ -591,7 +591,7 @@ blf_cbc_encrypt(blf_ctx *c, u_int8_t *iv, u_int8_t *data, u_int32_t len)
591
591
r = data [4 ] << 24 | data [5 ] << 16 | data [6 ] << 8 | data [7 ];
592
592
d [0 ] = l ;
593
593
d [1 ] = r ;
594
- Blowfish_encipher (c , d );
594
+ Vapor_Blowfish_encipher (c , d );
595
595
l = d [0 ];
596
596
r = d [1 ];
597
597
data [0 ] = l >> 24 & 0xff ;
@@ -608,7 +608,7 @@ blf_cbc_encrypt(blf_ctx *c, u_int8_t *iv, u_int8_t *data, u_int32_t len)
608
608
}
609
609
610
610
void
611
- blf_cbc_decrypt (blf_ctx * c , u_int8_t * iva , u_int8_t * data , u_int32_t len )
611
+ vapor_blf_cbc_decrypt (blf_ctx * c , u_int8_t * iva , u_int8_t * data , u_int32_t len )
612
612
{
613
613
u_int32_t l , r , d [2 ];
614
614
u_int8_t * iv ;
@@ -621,7 +621,7 @@ blf_cbc_decrypt(blf_ctx *c, u_int8_t *iva, u_int8_t *data, u_int32_t len)
621
621
r = data [4 ] << 24 | data [5 ] << 16 | data [6 ] << 8 | data [7 ];
622
622
d [0 ] = l ;
623
623
d [1 ] = r ;
624
- Blowfish_decipher (c , d );
624
+ Vapor_Blowfish_decipher (c , d );
625
625
l = d [0 ];
626
626
r = d [1 ];
627
627
data [0 ] = l >> 24 & 0xff ;
@@ -641,7 +641,7 @@ blf_cbc_decrypt(blf_ctx *c, u_int8_t *iva, u_int8_t *data, u_int32_t len)
641
641
r = data [4 ] << 24 | data [5 ] << 16 | data [6 ] << 8 | data [7 ];
642
642
d [0 ] = l ;
643
643
d [1 ] = r ;
644
- Blowfish_decipher (c , d );
644
+ Vapor_Blowfish_decipher (c , d );
645
645
l = d [0 ];
646
646
r = d [1 ];
647
647
data [0 ] = l >> 24 & 0xff ;
0 commit comments