During boot of an Ubuntu Core image we generate a device key on firstboot setup. This uses the rsa.GenerateKey() function from Go currently.
Tests have shown that this routine is significantly slower than using something like ssh-keygen or direct processing via libssl. This happens across all arches but since x86 is in general much faster here it has only been a real problem on ARM images where it is more noticeable (the Go routine is about 5.5 times slower than ssh-keygen in general, lots of test results are linked in the bug and PR below) and a key generation can take from 2-20 minutes.
While the initial PR was just shelling out to ssh-keygen, the security team had concerns about the nature of the setup:
"…ssh-keygen is an external program and has a configuration file that we’re not in control of."
Due to this the code was instead ported to use libssl directly now via cgo. The question that came up during a meeting today was if it is really that bad to use the ssh-keygen setup here given that we can have full control over it by hard-coding commandline options to make it not use any potential external configuration file.
Related bug:
https://bugs.launchpad.net/bugs/1638537
Proposed fix: