; ============================================================ ; crypto1_prng_gal.S - Crypto-1 functions (PRNG, implemented as Galois LFSR) ; ; Copyright (C) 2010-2013, Tomas Pecina ; ; This file is part of PICCE, an open source PICC emulator. ; ; PICCE is free software: you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation, either version 3 of the License, or ; (at your option) any later version. ; ; PICCE is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with this program. If not, see . ; #include "picce.inc" ; ============================================================ ; Data ; ; Register variables: ; crypto1_prng0 and 1 - PRNG state ; ; ============================================================ ; crypto1pshift - shift PRNG ; ; input: PRNG ; CL - number of turns ; output: PRNG shifted ; C flag - output bit ; uses: AL, CL ; .global crypto1pshift crypto1pshift: ldi AL, 0b10110100 1: clc ror crypto1_prng1 ror crypto1_prng0 brcc 2f eor crypto1_prng1, AL 2: dec CL brne 1b ret ; ============================================================ ; crypto1pout - output suc32(PRNG) ; ; input: PRNG ; X - pointer to data ; output: PRNG shifted ; 4 bytes of data ; uses: AL, AH, CL, CH, X ; .global crypto1pout crypto1pout: ldi AL, 0b10110100 ldi CH, 4 1: ldi CL, 8 2: clc ror crypto1_prng1 ror crypto1_prng0 brcc 3f eor crypto1_prng1, AL 3: ror AH dec CL brne 2b st X+, AH dec CH brne 1b ret .end