Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 07:32 23 Dec 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : PicoMite V6.00.01 release candidates - please test thoroughly

     Page 19 of 20    
Author Message
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4343
Posted: 07:35pm 20 Dec 2024
Copy link to clipboard 
Print this post

  Mark said  I appreciate all the work that everyone is doing on the V6 release. I just started testing with a Pico 2.

Other than links in messages this thread, is there a site where the latest release candidates can be found?

In one of the early posts this thread, a list of tested compatible software was given:

  Quote  
tested following programs
- 2048
- asciimovie
- blocks
- chemichaos
- circle
- flappyVGA
- flow-pico
- GemsNRocks
- LA
- Petrobot
- picoChess
- picoman
- rocks
- snake
- ZX81-maze


Is there a place where these (and other) programs can be downloaded?

Thanks,
Mark


Hi Mark,

These games are in my local archive. A link to the archive is also in the PicoMite VGA thread. Once 6.00.01 is released I will validate and update these games again to create a stable foundation for 6.00.01. Note these are tested on RC1, not RC9.

local archive

Volhout

P.S. I will look into your other problem later
Edited 2024-12-21 05:42 by Volhout
PicomiteVGA PETSCII ROBOTS
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4343
Posted: 08:12pm 20 Dec 2024
Copy link to clipboard 
Print this post

Hi Mark,

A program on disk is nice readable ASCII code. When a program is put in FLASH is is in binary (tokenized) form.
The FLASH DISK LOAD function loads binary data from DISK into the binary FLASH. But if you load an ASCII file into FLASH using FLASH DISK LOAD you cannot execute it, since it is not tokenized.

The normal way to put a program into FLASH is:

LOAD "Blocks.bas" 'to load it into RAM
FLASH SAVE 3 'this converts the AsCII program to binary, and stores it into FLASH


you can now execute the program with
FLASH RUN 3


Volhout
Edited 2024-12-21 06:14 by Volhout
PicomiteVGA PETSCII ROBOTS
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4343
Posted: 08:47pm 20 Dec 2024
Copy link to clipboard 
Print this post

Hi Peter,

In the 2040 VGA rc9 this does not work anymore (eats heap).

'start endless music now
Play volume 50,50  'adjust for best gameplay (0-100)
restartplay        'start music (endless loop)

'timed interrupt to restart the gameboy tetris tune when ended (1:16 duration)
Sub restartplay
 Play wav "tet16cut.wav",restartplay 'start music, and restart when end
End Sub


The WAV file is large (2.4Mbyte).
This is the background music for Geoff's Blocks.
Result is that the next command (and IF/THEN) cannot find the return (the THEN).

blocks local zip

Any idea ? I it worked on 2350 VGA rc9, but not 2040.

Volhout
Edited 2024-12-21 06:52 by Volhout
PicomiteVGA PETSCII ROBOTS
 
Mark
Regular Member

Joined: 26/11/2022
Location: United States
Posts: 50
Posted: 10:13pm 20 Dec 2024
Copy link to clipboard 
Print this post

Volhout,

Thanks for the link to your archives.

As for the flash issue, thanks for the explanation, it does indeed work your way.

Mark
 
homa

Guru

Joined: 05/11/2021
Location: Germany
Posts: 379
Posted: 10:29pm 20 Dec 2024
Copy link to clipboard 
Print this post

  matherp said  
  Quote  Why is iv supposedly optional if it is required? Is there a default value that might be missing?

iv is optional because the firmware has a value built in but it isn't all zeroes as that website assumes. To match the website you have to specify it as all zeroes to override the internal default. Dimming an array iv% sets it to zeroes



> list
'TEST aes128 cbc
'
Dim integer out2(15)
key$ = "1234567812345678"
in$  = "1234567890123456"
'iv$  = "1234567812345678"
iv$  = String$( 16, 0 ) 'nbr, ascii
'
Math aes128 encrypt cbc key$,in$,out2(),iv$
Math v_print out2(), hex
> run
74, 74, A4, 9E, 44, 98, B2, 49, D8, F6, 2E, F4, CF, 55, 41, A9
>

Yes, then it is a match :-)

Is this IV defined in the firmware? Or is it generated as a hash from the KEY? For transparency and security reasons, I would be interested to know how the default value is generated. Thank you very much!
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4066
Posted: 10:43pm 20 Dec 2024
Copy link to clipboard 
Print this post

Peter,

I suspect it would be better if the default IV were 0 rather than being an arbitrary constant in the firmware.

YMMV,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6126
Posted: 12:48am 21 Dec 2024
Copy link to clipboard 
Print this post

From http://www.ietf.org/rfc/rfc3602.txt.

2.1.  Mode

  NIST has defined 5 modes of operation for AES and other FIPS-approved
  ciphers [MODES]: CBC (Cipher Block Chaining), ECB (Electronic
  CodeBook), CFB (Cipher FeedBack), OFB (Output FeedBack) and CTR
  (Counter).  The CBC mode is well-defined and well-understood for
  symmetric ciphers, and is currently required for all other ESP
  ciphers.  This document specifies the use of the AES cipher in CBC
  mode within ESP.  This mode requires an Initialization Vector (IV)
  that is the same size as the block size.  Use of a randomly generated
  IV prevents generation of identical ciphertext from packets which
  have identical data that spans the first block of the cipher
  algorithm's block size.

  The IV is XOR'd with the first plaintext block before it is
  encrypted.  Then for successive blocks, the previous ciphertext block
  is XOR'd with the current plaintext, before it is encrypted.

  More information on CBC mode can be obtained in [MODES, CRYPTO-S].
  For the use of CBC mode in ESP with 64-bit ciphers, see [CBC].

...


3.  ESP Payload

  The ESP payload is made up of the IV followed by raw cipher-text.
  Thus the payload field, as defined in [ESP], is broken down according
  to the following diagram:

  +---------------+---------------+---------------+---------------+
  |                                                               |
  +               Initialization Vector (16 octets)               +
  |                                                               |
  +---------------+---------------+---------------+---------------+
  |                                                               |
  ~ Encrypted Payload (variable length, a multiple of 16 octets)  ~
  |                                                               |
  +---------------------------------------------------------------+

  The IV field MUST be the same size as the block size of the cipher
  algorithm being used.  The IV MUST be chosen at random, and MUST be
  unpredictable.

  Including the IV in each datagram ensures that decryption of each
  received datagram can be performed, even when some datagrams are
  dropped, or datagrams are re-ordered in transit.

  To avoid CBC encryption of very similar plaintext blocks in different
  packets, implementations MUST NOT use a counter or other low-Hamming
  distance source for IVs.



A random iv is the correct way to go.

Jim
VK7JH
MMedit   MMBasic Help
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9285
Posted: 08:49am 21 Dec 2024
Copy link to clipboard 
Print this post

Jim

Very interesting. I'd assumed the IV was like a second key that had to be known by the recipient but including it in the message makes much more sense. I'll make the changes to the encrypt code to use a random IV unless overridden and get rid of the IV option on the decrypt as I will include it in the message as the first block.
Does the same approach apply to CTR encryption?
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6126
Posted: 10:59am 21 Dec 2024
Copy link to clipboard 
Print this post

Sorry Peter, I have now exceeded my knowledge of encryption.
It just happens that PureBasic help had the link to the RFC so I could appear smarter than I really am.

PureBasic decrypt does have the IV field so don't throw it away totally just yet.

The problems will be when you are trying to communicate with something other than another picomite.

Jim
VK7JH
MMedit   MMBasic Help
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9285
Posted: 11:04am 21 Dec 2024
Copy link to clipboard 
Print this post

Please test the attached. RP2040 base version


PicoMite.zip

MATH AES128
All coding can now accept arrays of any length (subject to memory). Strings for encrypting are limited to 240bytes (EBR) and 224bytes (CTR and CBC)

For CTR and CBC encryption an output array, if used, must now be 16 elements BIGGER than the input. You can optionally specify an initialisation vector, otherwise a random vector is created.

For CTR and CBC decryption an output array, if used, must now be 16 elements SMALLER than the input (which now includes the IV). Therefore you no longer specify the initialisation vector for decoding as this is now included in the message as the first block

New functionality

MATH(BASE64 ENCRYPT/DECRYPT in$/in(), out$/out())
This base64 encrypts or decrypts the data in 'in' and puts the result in 'out'. This is a function that returns the length of the 'out' data. Where arrays are used as the output they must be big enough relative to the input and the direction so encryption increases length by 4/3 and decryption decrease it by 3/4

e.g.
Dim a$="1234567890",b$,c$
? math(base64 encrypt a$,b$)
? b$
? math(base64 decrypt b$,c$)
? c$

 
javavi

Senior Member

Joined: 01/10/2023
Location: Ukraine
Posts: 296
Posted: 12:07pm 21 Dec 2024
Copy link to clipboard 
Print this post

  matherp said  
  Quote  Does not allow arrays to occupy more than 180k of RAM memory, although there are still 48k left. If exceeded, it gives an error

The message is correct. Heap memory is full. Variable space for simple variables consumes the other 48K

In this case, the bad thing is that the MEMORY command does not display this. Is it possible to introduce a separate display of the HEAP memory and the simple variable memory separately?

 Also, when developing programs and configuring PicoMite, it would be good to have a built-in PINS command displaying information about their current state?
Edited 2024-12-21 22:23 by javavi
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9285
Posted: 12:31pm 21 Dec 2024
Copy link to clipboard 
Print this post

mm.info(heap) tells you how much is free
For the pins use the MMbasic subroutine

  Quote  Sub FREEPINS
Local n,gp$,p,pu$
 For n=0 To Choice(Instr(MM.Device$,"RP2350B"),47,29)
 gp$ = "GP"+Str$(n)
 p = MM.Info(pinno gp$)
 pu$ = MM.Info(pin p)
 Print gp$, p, pu$
Next
End Sub

That has a huge amount of C-code behind it which I am not going to replicate when it is so easy in Basic
 
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1303
Posted: 12:38pm 21 Dec 2024
Copy link to clipboard 
Print this post

I found some (for me) interesting information about the IV.
and wikipedia

What I can see (AFAIK) is that the IV (initialization vector) can be embedded as plain text in the encrypted file or is supplied with the key and is supposed to be random.

Thoughts on that?

Michael
causality ≠ correlation ≠ coincidence
 
homa

Guru

Joined: 05/11/2021
Location: Germany
Posts: 379
Posted: 04:35pm 21 Dec 2024
Copy link to clipboard 
Print this post

Yesterday: Talking to yourself or thinking out loud

How are the input values for AES actually filled according to the standard if they are not multiples of 128 bits?
Ok, it needs a bit of padding ... https://www.cryptosys.net/pki/manpki/pki_paddingschemes.html

Because of the Base64 question I found this ...
https://fruitoftheshed.com/wiki/doku.php?id=mmbasic:base64_mime_encode_and_decode_functions

Incidentally, is it planned and possible to use 'LONGSTRINGs' sometime?

Then, for example, a really small password management system is not far away...

Peter is already delivering today :-)
It's amazing!
All that remains is the question of long strings.
 
homa

Guru

Joined: 05/11/2021
Location: Germany
Posts: 379
Posted: 04:38pm 21 Dec 2024
Copy link to clipboard 
Print this post

  twofingers said  I found some (for me)interesting information about the IV.
and wikipedia

What I can see (AFAIK) is that the IV (initialization vector) can be embedded as plain text in the encrypted file or is supplied with the key and is supposed to be random.

Thoughts on that?

Michael


In any case, you need to know IV, otherwise you cannot decrypt the secret on another system, even if you know the key!

Matthias
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6126
Posted: 08:17pm 21 Dec 2024
Copy link to clipboard 
Print this post

My earlier reference to rfc3602 had a dot at the end.

The correct link should be
https://www.ietf.org/rfc/rfc3602.txt

The more I read, the more confusing it gets...

Jim
VK7JH
MMedit   MMBasic Help
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4343
Posted: 08:57pm 21 Dec 2024
Copy link to clipboard 
Print this post

Hi Peter,

There is a serious issue with PLAY WAV on RP2040 VGA 6.00.01rc9

On the commandline you can type PLAY WAV "yoursong.wav" and it plays.
In a program you can not.

Below is a minimal code to show the problem. It uses the tetris sound for Blocks.


PLAY WAV "tet16cut.wav"
if a=0 then print "a"


This errors with "Error : IF without THEN"
and does not play any sound.

Volhout
Edited 2024-12-22 06:58 by Volhout
PicomiteVGA PETSCII ROBOTS
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2183
Posted: 09:32pm 21 Dec 2024
Copy link to clipboard 
Print this post

2350 hdmi usb is ok


Edited 2024-12-22 07:36 by stanleyella
 
homa

Guru

Joined: 05/11/2021
Location: Germany
Posts: 379
Posted: 11:16pm 21 Dec 2024
Copy link to clipboard 
Print this post

  matherp said  Please test the attached. RP2040 base version

Do you still have an RP2350 version? At the moment I only have these on the playing field.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9285
Posted: 08:17am 22 Dec 2024
Copy link to clipboard 
Print this post

  Quote  There is a serious issue with PLAY WAV on RP2040 VGA 6.00.01rc9


Just need to finish off some work on AES128 and then I'll look at it. Pretty sure I know what the issue will be - firmware has outgrown the space allocated so programs are overwriting the firmware
 
     Page 19 of 20    
Print this page
© JAQ Software 2024