I'm building a virtual Keyring in our DB to allow users to store PGP/GPG public keys with relation to email addresses so that they can optionally encrypt all communications our system sends them. I'm just building the table now and wasn't sure about the column type to store the fingerprint.
From what I understand fingerprints will be 128 or 160 bits long, generally in the form of:
... which I believe is just a 32bit MD5 hash / UUID. I'm guessing I can store this as a 16bit Binary value, or a 32 char string...
Is there a best practice, and if so what is it, or lacking that, what's your preference?
As a related follow up, is there any reason to Encrypt the public key string itself, or is that redundant since it is public after all?
EDIT: BTW, this is MySQL currently 5.5, but will be 5.7 in the near future.**
EDIT 2: I can't find any examples out there of a table schema for storing this type of record and I admittedly have only minimal understanding beyond the basics of using public/private keys in my own role, so while I could discern that the fingerprint is a hash, I'm unaware of the different formats for public keys and what range their lengths can come in (i.e. what about the
-----BEGIN CERTIFICATE----- components, what size field will these need?).
If possible can someone provide a basic CREATE TABLE statement with what you see as an optimal fieldset? Below is what I've created thus far, is it sufficient, would you change anything?
CREATE TABLE `public_keys` ( `ai_col` int UNSIGNED NOT NULL AUTO_INCREMENT , /* ... other foreign keys ... */ `label` varchar(100) NULL , `fingerprint` binary(16) NOT NULL , `key_type` varchar(10) NOT NULL , `public_key` varchar(1024) NULL , PRIMARY KEY (`ai_col`) );