TLS Implementation ProgresslwIP has been seeing strides towards a full TLS infrastructure baked into ALTCP with an exposed API for people to use for other purposes. Here are some of the recent bits of progress.
1. SHA-256 is ported, HMAC wrappers are ported.
2. TLS rand is ported with a new algorithm that is computed to produce even more entropy than the previous... 100.2 bits of entropy per u64. See computations:
https://github.com/cagstech/lwip-ce/blo ... ls/INFO.md. The probabilities are based off the maximum allowable bias in the sampling.
3. AES CBC and GCM modes are ported -- I am dropping CTR. It's redundant of GCM but lacks authentication. CBC is there for file encryption mainly.
4. Base64 and ASN.1 are ported and an ASN.1 encoder is now provided as well. ASN.1 decode sports a better UI:
- Code: Select all
bool tls_asn1_decoder_init(struct tls_asn1_decoder_context *ctx, const uint8_t *data, size_t len);
bool tls_asn1_decode_next(struct tls_asn1_decoder_context *ctx, const struct tls_asn1_schema *schema, uint8_t *tag, uint8_t **data, size_t *len, uint8_t *depth);
Simply initialize the decoder with "init" and then loop "decode_next" until false is returned. This function automatically traverses the tree structure properly.
It also takes an optional parameter (NULL to omit) that is a schema. Essentially this allows you to create arrays of structs containing schema data for what field names, tag values, some flags, and depth are expected in various positions in the struct. The schema struct also has fields for if a tag is optional (a mismatch returns true anyway), whether null is allowed, or if this field output is wanted (if this is passed as false, the passed pointers to len, tag, data, and depth are not touched). To see how the schema allows for easy parsing, check out
https://github.com/cagstech/lwip-ce/blo ... eyobject.c5. It follows from the previous but decoding of PKCS#1, SEC1, and PKCS#8 public and private keyfiles is now fully supported. The user can generate a .pem file with openssl, run it through convbin to create an .8xv, send it to their calc and it should be recognizable by the keyobject module. This includes encrypted private keys although -- and this is very important --
the only algorithms that are supported for this are: PBES2 (password-based encryption scheme) using PBKDF2_HMAC with SHA-256 and ciphers AES-128-CBC or AES-256-CBC. For reference a command that can create what is needed is:
- Code: Select all
openssl pkcs8 -topk8 -inform PEM -outform PEM -in <private_key_path> -out <encrypted_key_path> -v2 aes-128-cbc -v2prf hmacWithSHA256 -iter <whatever>
Just remember this is a graphing calculator, so you probably want -iter to be something low. Like 100 (a few seconds) or 1000 (~30 seconds).
I plan to support for decoding X.509 structures as well, for reading certificates sent by remotes during handshakes.