Joined: Mon Mar 13, 2023 9:38 pm Posts: 80
|
Proxy wrote: so far my go-to RNG has been a function that takes a 32-bit number, splits it into 4x 8-bit pointers that point to a predefined set of 256 values. a number is read from each pointer, Added together, XOR'd, and Added again, to get a final result. and then increments the 32-bit number by 1. so it uses 4 bytes of Memory, and 256 bytes for the table+function (because the code of the function is used as part of the table, to save some memory) Code: .data rng_ptr: .res 4
.code rng_func: .A8 .I8 LDX a:rng_ptr LDY a:rng_ptr + 1 ; Get Pointers 0 and 1 LDA a:rng_func,X ; Get a byte from the RNG Table (using Pointer 0) CLC ADC rng_func,Y ; Add a byte from the RNG Table (using Pointer 1) to the Value LDX rng_ptr + 2 LDY rng_ptr + 3 ; Get Pointers 2 and 3 EOR a:rng_func,X ; XOR the Value with a byte from the RNG Table (using Pointer 2) ADC rng_func,Y ; And finally, Add a byte from the RNG Table (using Pointer 3) to the Value PHA ; Save the Output on the Stack INC a:rng_ptr BNE @s INC a:rng_ptr + 1 BNE @s INC a:rng_ptr + 2 BNE @s INC a:rng_ptr + 3 @s: PLA ; Get the Output from the Stack again, then Return RTS
; Function takes up 46 Bytes, so another 210 Bytes are required to fill the table .byte $54, $67, $87, $EC, $DF, $A0, $0F, $A0, $9E, $F9, $40, $03, $9A, $B7, $EE, $68 .byte $3C, $8E, $79, $B4, $D6, $1D, $E5, $43, $54, $65, $DB, $59, $A2, $A6, $AD, $A9 .byte $75, $50, $BB, $BA, $82, $F4, $D3, $3C, $50, $5E, $6A, $98, $2E, $49, $CB, $3F .byte $02, $53, $93, $8F, $EA, $24, $1C, $57, $F5, $F0, $AD, $3F, $65, $BA, $94, $A7 .byte $43, $12, $79, $CB, $30, $2F, $93, $2F, $BB, $94, $92, $A8, $BE, $AE, $5F, $88 .byte $66, $11, $0B, $BA, $FE, $48, $8C, $E2, $A4, $64, $21, $BF, $75, $A6, $78, $62 .byte $D8, $0A, $F9, $0F, $FA, $89, $CB, $BF, $A4, $47, $70, $A9, $F5, $1D, $16, $3F .byte $B3, $20, $F9, $90, $33, $1B, $74, $F6, $16, $25, $90, $79, $4D, $BA, $46, $61 .byte $30, $0B, $B5, $CA, $95, $6E, $FA, $48, $2E, $15, $7F, $E2, $A0, $7F, $DF, $F4 .byte $17, $4D, $BA, $BE, $54, $64, $12, $B7, $64, $8D, $17, $E2, $90, $F9, $70, $BE .byte $2D, $5B, $6B, $95, $5D, $80, $A1, $37, $E6, $92, $FE, $73, $B3, $71, $2F, $CB .byte $A6, $D7, $EE, $48, $CA, $1C, $AD, $5E, $09, $E8, $98, $3F, $01, $1B, $EC, $25 .byte $95, $B5, $1D, $5B, $4E, $93, $4A, $11, $B9, $44, $F2, $4C, $44, $46, $FE, $7D .byte $58, $73
since it just uses a 32-bit incrementing number it will repeat after 2^32-1 calls. I'm really sorry to tell you and I hope you won't get offended but your algorithm is not random at all and is full of short cycles. not at all 2^32. I guess you never did any tests on it, did you? The 46 bytes code + 210 bytes i used are :Code: $AE,$0D,$10,$AC,$0E,$10,$BD,$12,$10,$18,$79,$12,$10,$AE, $0F,$10,$AC,$10,$10,$5D,$12,$10,$79,$12,$10,$48,$EE,$0D,$10,$D0,$0D,$EE,$0E, $10,$D0,$08,$EE,$0F,$10,$D0,$03,$EE,$10,$10,$68,$60, $54, $67, $87, $EC, $DF, $A0, $0F, $A0, $9E, $F9, $40, $03, $9A, $B7, $EE, $68, $3C, $8E, $79, $B4, $D6, $1D, $E5, $43, $54, $65, $DB, $59, $A2, $A6, $AD, $A9, $75, $50, $BB, $BA, $82, $F4, $D3, $3C, $50, $5E, $6A, $98, $2E, $49, $CB, $3F, $02, $53, $93, $8F, $EA, $24, $1C, $57, $F5, $F0, $AD, $3F, $65, $BA, $94, $A7, $43, $12, $79, $CB, $30, $2F, $93, $2F, $BB, $94, $92, $A8, $BE, $AE, $5F, $88, $66, $11, $0B, $BA, $FE, $48, $8C, $E2, $A4, $64, $21, $BF, $75, $A6, $78, $62, $D8, $0A, $F9, $0F, $FA, $89, $CB, $BF, $A4, $47, $70, $A9, $F5, $1D, $16, $3F, $B3, $20, $F9, $90, $33, $1B, $74, $F6, $16, $25, $90, $79, $4D, $BA, $46, $61, $30, $0B, $B5, $CA, $95, $6E, $FA, $48, $2E, $15, $7F, $E2, $A0, $7F, $DF, $F4, $17, $4D, $BA, $BE, $54, $64, $12, $B7, $64, $8D, $17, $E2, $90, $F9, $70, $BE, $2D, $5B, $6B, $95, $5D, $80, $A1, $37, $E6, $92, $FE, $73, $B3, $71, $2F, $CB, $A6, $D7, $EE, $48, $CA, $1C, $AD, $5E, $09, $E8, $98, $3F, $01, $1B, $EC, $25,$95, $B5, $1D, $5B, $4E, $93, $4A, $11, $B9, $44, $F2, $4C, $44, $46, $FE, $7D, $58, $73
A lot of FIPS 140-2 tests failed :Quote: rngtest: starting FIPS tests... rngtest: bits received from input: 40000032 rngtest: FIPS 140-2 successes: 1162 rngtest: FIPS 140-2 failures: 838 rngtest: FIPS 140-2(2001-10-10) Monobit: 54 rngtest: FIPS 140-2(2001-10-10) Poker: 788 rngtest: FIPS 140-2(2001-10-10) Runs: 279 rngtest: FIPS 140-2(2001-10-10) Long run: 0 rngtest: FIPS 140-2(2001-10-10) Continuous run: 0 rngtest: input channel speed: (min=22.980; avg=2929.425; max=9536.743)Mibits/s rngtest: FIPS tests speed: (min=2.272; avg=16.170; max=16.894)Mibits/s rngtest: Program run time: 2374486 microseconds
All al lot of short cycles, I stopped the test well before 2^32 : The first 20-byte sequence repeats non-stop : Quote: Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 0 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 194E ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index EE72 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 1933CE ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 194D1C ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 1A2240 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index AF0D5D ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index AFBF9A ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index EE505C ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index EE69AA ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index EF3ECE ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 1614E00 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 162003D ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 19304FE3 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 19306931 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 19313E55 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 194983B1 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 19499CFF ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 194A7223 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 19DF5D40 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 19E00F7D ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 1A1EA03F ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 1A1EB98D ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 1A1F8EB1 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 1A919DE3 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 1A925020 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 3261FF8E ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 327B296C ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 330F2737 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 330F30EF ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 330F3AAE ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 330F446D ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 330F6965 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 3310A765 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 33503E8A ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 33C16908 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 33C172C0 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 33C17C7F ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 33C1863E ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 33C1AB36 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 33C2E936 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 3C1204AE ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 3C2B2E8C ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 3CBF2C57 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 3CBF360F ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 3CBF3FCE ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 3CBF498D ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 3CBF6E85 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 3CC0AC85 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 3D0043AA ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 3D716E28 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 3D7177E0 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 3D71819F ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 3D718B5E ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 3D71B056 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 3D72EE56 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 45C21AB1 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 45DB448F ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 466F425A ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 466F4C12 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 466F55D1 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 466F5F90 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 466F8488 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 4670C288 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 46B059AD ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 4721842B ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 47218DE3 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 472197A2 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 4721A161 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 4721C659 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 47230459 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 4F7224BD ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 4F8B4E9B ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 501F4C66 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 501F561E ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 501F5FDD ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 501F699C ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 501F8E94 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 5020CC94 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 506063B9 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 50D18E37 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 50D197EF ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 50D1A1AE ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 50D1AB6D ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 50D1D065 ! Found 'A0C3BEA2C0BE731CBE16371CBEA0C1BEA2BEBE53' at index 50D30E65 !
Last edited by Alex1 on Tue Mar 14, 2023 2:23 pm, edited 1 time in total.
|
|