Sign inSign up

wonderbitcom/openabe_rest

By wonderbitcom

Updated over 5 years ago

Implementation of REST functionality on top of the Open Attribute Based Encryption (Open-ABE).

Image
0

237

wonderbitcom/openabe_rest repository overview

OpenABE Rest

About

This is an implementation of REST functionality on top of the Open Attribute Based Encryption (Open ABE). It uses Flask and Flask-RESTful on top of the os commands provided by touatily's openabe.

*A suggestion would be to use POSTMAN for sending requests. Otherwise you may need to escape characters in the keys or in the ciphertext.

When first starting this application, generate a master key. You only need to generate the master key once, but you can do it as many times as you want using the URLs below.

Usage

# pull the docker images
$ docker pull wonderbitcom/openabe_rest:latest

# run the container
$ docker run -p 5000:5000 --name cpabe_rest --rm -d -e PYTHONUNBUFFERED=0  wonderbitcom/openabe_rest:latest

# see logs (CTRL+C to exit)
$ docker logs cpabe_rest -f

# stop the running container
$ docker stop cpabe_rest

# generate master key
# this will replace any existing master key and will make any generated secret keys absolete
$ curl --request GET localhost:5000/generate_mk
{
    "detail": "master key generation success"
}

# generate user secret key
# the attributes need to be divided by `|`
$ curl --request POST localhost:5000/generate_sk --data 'attributes=cyber|iot'
{
    "sk": "AAAAGapvybTpNU3LzZQHntvmIwOwVfdkZWNLZXkAAAEEoQFLoUSzoUECFvu3zwzQwIeFX32TiW2TBcc6MViTwZ7c9HNoJNSCYQASBSoNEDdkJt3sUdpavdjWoyDKZKbtS7mBYuo8byzJtaEIS1hfY3liZXKhJLKhIQMKnRBI4yMftd9A+Tur3s50QvfGxF/IQk62hhjhHgeg56EGS1hfaW90oSSyoSEDFaVEkfzxoL8OAh8tcIxHMczd0dxV1dSXcr8HMpNz0G2hAUyhRLOhQQMXvVQp96yn3ViApR2dJfyJctvnC7nTWl/UqD48Mn7sCxXj+JbTyjjT8cuUfXpr7Lmva9gXiyZvmj/ly4aJ6EEMoQVpbnB1dKELfGN5YmVyfGlvdHw="
}

# encrypt data with a specific policy
# it uses the public mk generated previously
$ curl --request POST localhost:5000/encrypt --data 'policy=cyber&plaintext=Hello world!'
{
    "ciphertext_abe": "oROqb8kyVBA3sX/U3yZWRDDKWsRasgEMoQdDX2N5YmVyoSSyoSEDI9Q4Cf1NOzXyx3KOCMV5VdOyYJc3V5q2S90KKEZUDs2hBkNwcmltZaEksqEhAxKpbqSlVj9rWbK662N3hahm7SiyxTTBaI8kaJG1PP1EoQdEX2N5YmVyoUSzoUECGYNuOKNXjs6bEqYfXv3Qtyv/YxbP8KgWi67YjyOA+6wVenwWb4Ehp9cWGjhBjr+r4oXtBXHW8zhvNyPfU+mybaEDX0VEoUUdAAAAQEMRNdwlZ/JVlSY+pSkwMjeltDkC9uIfpx5E56iOYRC+wUlrCRImCh2LnhukKg1KoT1F5ujngJb0EJG+ieRvNs2hBnBvbGljeaEKHQAAAAVjeWJlcg==",
    "ciphertext": "oVChAkNUoRMdAAAADnZEGO5tW8M1dM+WNFduoQJJVqEVHQAAABAKs/g1bLC7QBYmUxAVQ15ooQNUYWehFR0AAAAQyzO3mYY0hS31Obi3sfzvcg=="
}

# decrypt data with a sk
$ curl --request POST localhost:5000/decrypt --data-urlencode 'sk=<your_sk>' --data-urlencode 'ciphertext_abe=<ciphertext_abe>' --data-urlencode 'ciphertext=<ciphertext>'
{ 
    "plaintext": [ "Hello world!" ] 
}

Tag summary

Content type

Image

Digest

Size

1.2 GB

Last updated

over 5 years ago

docker pull wonderbitcom/openabe_rest