Project

jsign

0.0
No commit activity in last 3 years
No release in over 3 years
Jsign uses OpenSSL to sign JSON serialisations. The signed objects are valid JSON objects themselves.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

>= 0
 Project Readme

Jsign

For signing your JSON serialisations.

Jsign presents a dead-simple API for generating and verifying private-RSA-key-signed JSON serialisations. It is minimally intrusive into the serialised object, adding a single top-level key-value pair.

For now, the digest is hard-coded to sha256, and the key algorithm is fixed as RSA. I'll loosen these when there's a need.

Howto

require 'jsign'

json = '{"a":1}'
private_keyfile = "~/sekrit/mykey.pem"
signed_json = Jsign.sign(json, private_keyfile)

# somewhere else, a short time later

public_keyfile = "~/public/mypub.pem"
if Jsign.verify(signed_json, public_keyfile)
  puts "All is well with the world."
else
  raise "DIUERSE ALARUMS!"
end

How it works

Jsign signing does the simplest thing that can possibly work: it rewrites the json string with the signature without actually parsing the JSON at all. The only requirement for this to work is that the JSON serialisation finishes with a '}' character.

TODO

  • Figure out an API to support more than one key type
  • add a Jsign.unsign method to get rid of the superfluous key/value pair

License

Public domain.