Update
I have been away for a few weeks, traveling for a wedding, and then recovering from it. My hands are still a bit stiff, so this update will be concise, and also very raw.
Our last update was actually in the Improving Memory thread, and progress has occurred since.
Weekly meeting notes
The notes of the last several weekly botan meetings have piled up, so the following summation covers the 3-4 meetings since the last update to this thread.
A Weekly meeting
- Discussion regarding long-term planning, eg “where is this going”
- There needs to be an easily-understood plan
- Value needs to be provided at each step
- Each step needs to carry us towards our long-term goal
- Need to create / illustrate the plan better
- Discussion over deciding how to handle updates & deprecations eg how we do version vs botan versioning
- Joris’s recent work on managing / detecting the botan install helps a lot here
- Discussion over new / known issue - clean up of memory objects
- There are some memory leaks eg the random context (one of the oldest parts of the library)
- Also in general Haskell does not guarantee immediate cleanup
- It relies on GC which might not happen until program close
- This is the quintessential problem - improving prompt cleanup - issue 68 - This is actually one of the core reasons why I am working on ‘Improving
memory’
The next weekly meeting
-
Weekly now include @jmct in addition to joris and myself
-
Joris was out traveling
-
My update was posted to the Improving Memory
-
Discussion and planning of immediately applicable integration of memory support wrt/ cryptography
- Better support for control over & immediate cleanup of memory
- Breaking up Data.Bits into Boolean, BitAddressable, ByteAddressable
- Lots of pedantry over address space classification
- Breaking
ByteArray/Access into Allocator & Array classes
- Generalizing ByteArray into eg
MemArray Byte
- Finite lifespan memory protected by bracket / uninterruptable masks
Last last week’s meeting
- Gone for a wedding, no time and bad internet
- Discussion of the interface problem
- Applies to both memory and cryptography
- There are many different ways to surface the functionality that we need
- It is difficult to efficiently describe cryptography in Haskell
- It is necessary to describe memory to describe cryptography
- Eg, forcing a pure description onto it is possible but slow
- Still doesn’t capture eg secure allocation and erasure
- Reducing them down to 4 main camps, eg
- Pure-ish
- Monadic
- Linear
- Effects
- Which is ‘best’ is a matter of opinion
- Most common cases first
- Going to focus on providing the most popular interfaces from
memory first - monadic & IO, with some pure wrappers that use unsafePerformIO under the hood
- Mostly read up on linear haskell and effect systems
- Definitely need linear haskell interface at some point
- Extremely valuable for describing memory ops in a pure context
- Should probably be a separate library
- Secondary / low priority
- applying the OG to botan comes first
- necessary for a linear-botan
- Third interface style would require an effect + co-effect system
- Implicit parameters are a co-effect so it makes sense to implement ‘the allocator’ as one
- This is relevant to the question of ‘multiple allocator instances’ - doesn’t exactly solve it unless you add a scoping law
- Implies we should have official implementations for popular effect libraries
- Tertiary / very low priority - way future but good to have decided now
- Did realize that one of the questions posed doesn’t actually have one answer - the allocator reference problem
- There are smart pointers that know their owner
- There are allocators that can query an address for ownership
- Allocators can stack, so an address-pointer is owned by every allocator in the ancestry stack
- Not every allocator / pointer can free / be freed
- Stack allocators dont free, they rewind.
- So ultimately, there has to be multiple typeclasses for these cases
- They are low priority though, basics first
- Discussion over algorithm identifiers
botan-low uses string identifiers (and functions to generate string identifiers)
- Question: Why not data types?
- Answer: string symbols suffice for lower-level because it is near 1:1
- ADTs are planned for in
botan
- Discussion: Generating bindings automatically via hs-bindgen
- give a C header file and generates the foreign imports
- first version of botan-bindings handwritten
- not bad for first pass
- difficult to maintain
- can test against handwritten bindings to verify behavior when changing to generated bindings
- we are considering using hs-bindgen to generate much of the lower bindings to lower the maintenance burden
Last week’s meeting
- Recovering from travel, health was priority this last week
- Worked on refining plans, making diagrams (easier than typing)
- Have prepped plan for sets of libraries vs interfaces
- Has made it easy to focus on the present task, memalloc
- memalloc is starting to take shape
- still have plenty of open questionss
- focusing on useful things
- Breaking apart bytearray/access into allocator, array, and memory(?)
- allocators, layouts and allocations
- memory regions, addresses (still pondering)
- references, pointers, and arrays
- ideas for how to represent mutability
- that is, have illustrated the different interfaces
- eg, primmonad / primstate
- various support for bracketing for secure stuff
- Breaking apart bytearray/access into allocator, array, and memory(?)
- allocRet is strange but its… complex
- it does too much - combines allocation with initialization with arrays
- initializable memory - eg write-once vs readwrite
- Balancing immediate goal of replicating
memory’s most popular functionality vs providing a better interface
- Discussion: How does improving
memory via memalloc serve botan?
- Need memalloc for botan-low allocators
- Need for cryptography abstractions
- Need for botan implementations
This week’s update
Now that we’ve caught up with the present:
This week’s meeting notes
-
Discussion of repo organization and ownership
- Re: Organization: Keeping related libraries of the same topic in the same repo
- Eg
botan, botan-low, and botan-bindings in one repo
memalloc in its own repo
- Re: Ownership of
memalloc
- Easier just to also publish & be managed by HF (like botan)
- Helps share responsibility & burden - many hands make light work
- Lets me focus on long term plans
-
Discussion of getting used in more real-world applications
- Eg getting
botan in a better position to replace / provide an alternative cryptonite
-
Joris: looking at today - hsbindgen
- tricky bits how to support multiple C++ versions
- problematic because botan version macro support needed
- might have to annotate our own
- different versions vs one haskell version with conditional compilation
- Botan backwards compatibility is a concern
- Botan 4.0 possibly
- knows that the unix package does conditional compilation
- api is same but get runtime errors if using unsupported thing
- this matches the one haskell version
- there are functions for querying support of conditionally compiled features such that we can allow the user to check and avoid hitting the runtime exception
- writing a script to help automate this
- ideally make maintaining botan-bindings easier / more simply
- user story about how to support it properly now and in the future
-
This weeks goals:
- Publish this update
- Get a git repo up to get eyes on
memalloc
Maintenance
A summation of the past few weeks:
Joris has continued to maintain botan-bindings and botan-low, working on:
- Refactoring the test suites to get rid of the need for multiple test targets
- The sheer number of permutations needing to be tested caused problems
- Original fast dirty solution had a different test target for each cryptographic operation
- Now there is one test suite, and we can now specify subtests and filter more easily, which also helps with generating a coverage report
- merged test suite refactoring
- Fixed some bugs (some were managing botan bugs)
- Botan released new version - looking at changelogs but it builds out of box with our library so maybe no change needed not done yet
- Finished fixing last 2 bugs in CI
Planning
This is my diagram of plans & progress:
Right now I am churning through memalloc, and although there are still open questions, I am reaching the stage where I am not just designing interfaces and have now started transplanting / translating functions from memory.
I’m finding most functions to be rather straightforward, and though the addition of an allocator argument does cause some additional gruntwork, the resulting framework is cleaner, and the Layout type is doing me proud - I have successfully written allocators covering the C Stdlib malloc and free, as well as GHC’s garbage-collected ByteStrings.
Health
I don’t know what my sustained pace is going to be like, but I’ve settled in quite nicely so far, and I’m taking care of my hands.
Responding
I have many messages and things to respond to. I will get to all of it.
I am joining the Haskell Foundation
I am also pleased to announce that I will be officially joining the Haskell Foundation. This will help keep everything organized and moving along at a good pace.
