Showing posts with label #rsa. Show all posts
Showing posts with label #rsa. Show all posts

Sunday, January 3, 2016

Tip o' the Day - Converting PEM files to PKCS12



Another thing that should be easy but took way too damn long to figure out.  Some of the newer crypto libraries only take pkcs12 keys - which is huge overkill for almost everything.  To convert the mundane PEM format to pkcs12 is a huge pain - you need to have a signing authority to sign the key.  To follow the flow, you can just self-sign the key with the PEM itself.  For instance:

# create a cert from our original ECDSA pem file - dont use a password unless you really need
openssl req -new -x509 -key pem.txt -out damncert.pem -days 730
# can check it just for grins, i'm paranoid
openssl x509 -in damncert.pem -text -noout
# convert the key to pkcs12 and sign with the same key to shut up the convert

openssl pkcs12 -export -out pkcs12_outfile -inkey pem.txt -in damncert.pem


PKCS12 isn't Microsoft's PFX - so this probably won't work with Microsoft's stuff.


SEO rules say I'll get more Google hits with media.  So here's a picture of my cat on a ladder.  :-)

Wednesday, July 8, 2015

Census Protocol and Wallets

I started using (and fixing incidentally, if somebody wants to volunteer to help :-P ) the Census Protocol python library and it seems pretty handy so far.  I haven't pushed my latest changes to git yet - so if you're anxious just chill.  There was a bunch of stupid errors in the library as is that I just fixed.  Easiest thing to start with is the Census version of "Hello World."

The Census Protocol is a blockchain application that's made to send and record the possession of virtual goods. The software itself is planned to be open source - but it's not widely available yet since it's changing a lot still. A small cabal (sorry – I just like that word :) ) are working on it now and breaking each others changes the way that only nerds can – but hopefully it should be pushed to the public repo soon.

To verify the local node is running and mostly works - asking its version is the simplest.  This is through /api/v1/version or just using the version call in the library.


__author__ = 'lpreimesberger'
import censusprotocollib
import json

print "Hello world!  I'm trying to talk to the blockchain server on this host!"
print json.dumps( censusprotocollib.version("localhost"), sort_keys=True, indent=4, separators=(',', ': '))
print "Tada!"

Running this gives the expected output on my local system:
lpreimesberger@dadbuntu:~/projects/testthelibrary$ python testversion.py  

Hello world!  I'm trying to talk to the blockchain server on this host!
"{\"result\":\"ok\",\"vendor\":\"census foundation baseline implementation\",\"version\":{\"core\":\"0.01\",\"hard_fork\":1}}"
Tada!



Good start, right? Well, okay - that's pretty useless. You could do that in a web browser after installing the base packages.

Everything in Census is based around the wallets - if a node doesn't think there's a valid wallet existing in the blockchain (or at least its local coinbase) it will reject any item transfer to that address. For local submissions – it's rejected outright. If they are sent from other nodes they remain eternally in the graveyard until the consensus says they are good or the node sees a valid wallet create with a valid signature pass.

Next post will be trying to query the local database (again, baby steps) – and then using the library to generate a new wallet and try to do something useful. Since the wallets contain valid ECDSA and RSA public keys – we can probably make a ghetto PGP application pretty quickly.