ganavel9783
Member level 1
p16_tiri.asm
Hi every1,
Recently i posted a thread regarding text file encryption implementation in PIC16f877 using the AES algorithm.I was advised by ric to work with block of 16 bytes first before i could proceed with encryption.Eventually, i manage to send block of 16 byte serially by using my own PC application.The serial code that i'm using in the PIC is adapted from AN774(P16_tiri.asm:Use interrupts for transmit and receive,circular buffer,eight bit data).For ur information,my PC application sends data by this manner:
So, when the PIC buffer is full(i set the buffer at 16 byte) the PIC will test the next byte from the RCREG to detect whether the carriage return byte is received or not before its being discarded.Once the carriage return is received the 16 byte data in RxBuffer will be copied to TxBuffer before its transmited back to PC.Thats generally how the 16 byte data transfer works for my application.Having this done, i thought of encrypting the 16 byte data in the RxBuffer before its copied to the TxBuffer.
So, i included the AES implementation from AN821 to add the encryption subrountine to p16_tiri.asm.I upgraged my pc application so that i could send data in this manner:
Pls, note that i'm using a fixed key for both encryption & decryption.Whenever the buffer is full, the PIC will try to detect the next byte to distiguish whether the data in the buffer is for encrypting or decrypting.However, i noticed that everytime i tried to send a text file larger than 16 byte the encryption result gets truncated after the first block of 16 byte.Same thing happens when i tried to decrypt a text file more than 16 byte.
So, should i place a delay in my pc application so that it sends blocks of 16 bytes to PIC16f877 until the block before is encryptd and send back to PC??
Hi every1,
Recently i posted a thread regarding text file encryption implementation in PIC16f877 using the AES algorithm.I was advised by ric to work with block of 16 bytes first before i could proceed with encryption.Eventually, i manage to send block of 16 byte serially by using my own PC application.The serial code that i'm using in the PIC is adapted from AN774(P16_tiri.asm:Use interrupts for transmit and receive,circular buffer,eight bit data).For ur information,my PC application sends data by this manner:
<8 byte data+ 8 byte data> + <carriage return byte>
So, when the PIC buffer is full(i set the buffer at 16 byte) the PIC will test the next byte from the RCREG to detect whether the carriage return byte is received or not before its being discarded.Once the carriage return is received the 16 byte data in RxBuffer will be copied to TxBuffer before its transmited back to PC.Thats generally how the 16 byte data transfer works for my application.Having this done, i thought of encrypting the 16 byte data in the RxBuffer before its copied to the TxBuffer.
So, i included the AES implementation from AN821 to add the encryption subrountine to p16_tiri.asm.I upgraged my pc application so that i could send data in this manner:
<8 byte data+ 8 byte data + <carriage return byte> ===>for encryption
<8 byte data+ 8 byte data + <line feed byte> ===>for decryption
Pls, note that i'm using a fixed key for both encryption & decryption.Whenever the buffer is full, the PIC will try to detect the next byte to distiguish whether the data in the buffer is for encrypting or decrypting.However, i noticed that everytime i tried to send a text file larger than 16 byte the encryption result gets truncated after the first block of 16 byte.Same thing happens when i tried to decrypt a text file more than 16 byte.
So, should i place a delay in my pc application so that it sends blocks of 16 bytes to PIC16f877 until the block before is encryptd and send back to PC??