I spoke to :jcj about doing this with some of our existing crypto libs:
you’ll be working with the higher-level PK11_Encrypt / PK11_Decrypt functions (included via nss.h) . https://searchfox.org/mozilla-central/source/netwerk/srtp/src/crypto/cipher/aes_gcm_nss.c#284 might be a useful general reference about how to set things up and call — while it’s using GCM instead of CTR or CBC, at broad strokes it’s a decent enough pattern
It's not in stone we'd want to go this route, but it would be nice to leverage existing works for clearkey if we can. We may also wish to consider replacing some of the existing clearkey cenc machinery if possible.