Poke Register AES_MODE_REG[2:0]

Here we can discuss about the problem found
Bishopxxl
Posts: 18
Joined: Tue Oct 08, 2024 5:47 pm
Has thanked: 22 times
Been thanked: 6 times

Poke Register AES_MODE_REG[2:0]

Post by Bishopxxl »

Hello ,

I have a question: Could it be that a poke or a peek doesn't work with all registers.
I just wanted to play with the AES registers because I noticed that either the Poke or the Peek always produces a 0.
Or does the module have to be explicitly correct in the config. Currently on Generic.
I also tried an M5Stack Core 2 and it doesn't work either.
Maybe I'd rather wait for the "New Release 1.80.1 with AES :D
Or.... I'm just too stupid LOL

Bishopxxl

Code: [Local Link Removed for Guests]

Bas.Poke &H3FF01008, &H02
Pause 20
A = Bas.Peek (&H3FF01008)
Pause 20
WLog Hex$(A)

wait
User avatar
cicciocb
Site Admin
Posts: 2781
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 592 times
Been thanked: 1990 times
Contact:

Re: Poke Register AES_MODE_REG[2:0]

Post by cicciocb »

I don't think you are stupid, probably the aes cannot be simply be used peeking and poking into registers. I already implemented, together with base64 conversion, into the iobuffers. It will be in next release that should be available in few weeks
Bishopxxl
Posts: 18
Joined: Tue Oct 08, 2024 5:47 pm
Has thanked: 22 times
Been thanked: 6 times

Re: Poke Register AES_MODE_REG[2:0]

Post by Bishopxxl »

Hello cicciocb
many thanks for your response. Then I will be patient.
I just thought it could work with poke/peek.
The datasheet actually describes the process well.
Even a start bit for execution is listed there.
What surprises me is that the registers are R/W.
No matter, I'll start working on my crc16 routines now.

Thank you !!

Bishopxxl
grafik.png
grafik.png
You do not have the required permissions to view the files attached to this post.
User avatar
cicciocb
Site Admin
Posts: 2781
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 592 times
Been thanked: 1990 times
Contact:

Re: Poke Register AES_MODE_REG[2:0]

Post by cicciocb »

I could also implement some CRC algo, I need to check
Bishopxxl
Posts: 18
Joined: Tue Oct 08, 2024 5:47 pm
Has thanked: 22 times
Been thanked: 6 times

Re: Poke Register AES_MODE_REG[2:0]

Post by Bishopxxl »

Hello cicciocb,
I currently use two CRC16 routines. One is CRC-16/IBM-3740 and the other is the CRC-16/MCRF4XX (Microchip).
Yes, it would be great if the parameters could be specified (for unisersal CRC16), e.g. Poly Init RefIn RefOut XorOut.
For me it would be ok (because of the speed) if it was a calculation and not a table.

https://crccalc.com/?crc=123456789&meth ... &outtype=0

Example :

Code: [Local Link Removed for Guests]

' CRC16-CCITT-Berechnung im Annex32 Basic, erwartetes Ergebnis 0x29B1
 
' Beispiel-String für die CRC-Berechnung
testString$ = "123456789"
crc = &HFFFF  ' Startwert für CRC
 
' CRC-Wert berechnen
FOR i = 1 TO LEN(testString$)
    byteVal = ASC(MID$(testString$, i, 1))
    crc = (crc XOR (byteVal << 8))  ' XOR mit dem Byte, nach links verschoben
    FOR j = 0 TO 7
        IF (crc AND &H8000) THEN
            crc = (crc << 1) XOR &H1021  ' Polynom verwenden
        ELSE
            crc = crc << 1
        ENDIF
    NEXT j
NEXT i
 
crc = crc AND &HFFFF  ' Maskierung auf 16 Bit
 
' CRC-Wert mit WLOG ausgeben
WLOG "CRC16-CCITT für '" & testString$ & "' = "; HEX$(crc)




Bishopxxl

Technical Parameters of CRC-16/MCRF4XX

This CRC variant has the following parameters:

Polynomial: 0x1021 (which corresponds to the polynomial x16+x12+x5+1x16+x12+x5+1)
Initial Value: 0xFFFF
Reflection: Data is not reflected during the CRC calculation (no bit reversal).
Output XOR: No additional XOR operation is applied at the end of the calculation.

Technical Parameters of CRC-16/IBM-3740

The CRC-16/IBM-3740 variant, also known as CRC-16/ANSI or simply CRC-16, has these specific parameters:

Polynomial: 0x1021 (hexadecimal), which corresponds to the polynomial x16+x12+x5+1x16+x12+x5+1.
Initial Value: 0xFFFF.
Reflection: Neither input data nor output checksum are reflected (i.e., no bit reversal is applied).
Output XOR: No additional XOR operation is performed on the output.
Bishopxxl
Posts: 18
Joined: Tue Oct 08, 2024 5:47 pm
Has thanked: 22 times
Been thanked: 6 times

Re: Poke Register AES_MODE_REG[2:0]

Post by Bishopxxl »

Hi,

I think that's my problem with AES128 / PEEK-POKE

:)
Unbenannt.png
You do not have the required permissions to view the files attached to this post.
User avatar
cicciocb
Site Admin
Posts: 2781
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 592 times
Been thanked: 1990 times
Contact:

Re: Poke Register AES_MODE_REG[2:0]

Post by cicciocb »

Yes, parts of the CPU cannot be controlled directly but only using the internal SDK functions.
User avatar
cicciocb
Site Admin
Posts: 2781
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 592 times
Been thanked: 1990 times
Contact:

Re: Poke Register AES_MODE_REG[2:0]

Post by cicciocb »

Implemented the AES128 and the CRC in the version 1.70.2
Bishopxxl
Posts: 18
Joined: Tue Oct 08, 2024 5:47 pm
Has thanked: 22 times
Been thanked: 6 times

Re: Poke Register AES_MODE_REG[2:0]

Post by Bishopxxl »

Hello cicciocb,
Thank you for implementing the AES128 function.
I've been trying to get it to work for a while.
Unfortunately I can't manage to place a hex "00" in the key or in the plain.
I've also tried IObuff.FromHex - unfortunately without success.
In the plaintext and in the Key$, a &H00 is difficult because it is a string.

Code: [Local Link Removed for Guests]

'key$ = "my_Personal_key1"             ' Sets the crypting key
'key$ = "my" + chr$(95) + "Personal_key1"             ' Sets the crypting key
key$ = "my" + chr$(00) + "Personal_key1"             ' Sets the crypting key
wlog key$
IObuff.FromString(0, "Hello, World!") ' Converts a string into IO Buffer
print IObuff.Encrypt(0, key$)         ' Encrypts using a 16 characters key
wlog IObuff.ToHex$(0)                 ' Shows the result in Hex format
wlog IObuff.Decrypt(0, key$)  ' Decrypts using the same key
wlog IObuff.ToString$(0)   ' shows the decrypted string (same as the original)

Invalid Key line 6
23/11/2024 16:17:05 -> Program Stopped

Cheers Bishopxxl
User avatar
cicciocb
Site Admin
Posts: 2781
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 592 times
Been thanked: 1990 times
Contact:

Re: Poke Register AES_MODE_REG[2:0]

Post by cicciocb »

You cannot use the character &h00 inside the strings so you cannot use it for the key (but do you really need a &h00 inside the key?).

But you should be able to use the \0 inside the message (using iobuffer.fromHex) but you are right, I think something is not working properly.
I did a mistake somewhere .....
Post Reply