Json-reference

Basic Rules

When you send a json to Coherence, it only accepts (something like base64):

alphanum + "!\"#$%&\'()*+,-./:;<=>?@[\]^_`{|}~ "

#!/usr/bin/env python

import socket
import json
import os,binascii

def sending(message):
    ip = '127.0.0.1'
    port = 6613
    BUFFER_SIZE = 65536
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect((ip, port))
    s.send(message)
    data = s.recv(BUFFER_SIZE)
    s.close()
    return data

data_js='{"version":1,"algorithm":"SHA3_512","type":"string","plaintext":"616263","hex":1}'
sending(data_js)

Substitute data_js with your own json

Hash

Apply hash sha3_512 to hex string "616263"

{"version":1,"algorithm":"SHA3_512","type":"string","plaintext":"616263","hex":1}

Apply hash sha3_512 to string "mayhem"

{"version":1,"algorithm":"SHA3_512","type":"string","plaintext":"mayhem","hex":0}

Apply hash sha3_512 to string "mayhem"

{"version":1,"algorithm":"SHA3_512","type":"string","plaintext":"mayhem"}

Apply hash sha3_512 to file "mayhem.txt"

{"version":1,"algorithm":"SHA3_512","type":"file","file":"mayhem.txt"}

  • algorithm: (SHA3_512, SHA3_384, SHA3_256, SHA3_224, SHA_512, SHA_384, SHA_256, SHA_224, SHA_1 ,WHIRLPOOL , BLAKE2B)

  • plaintext hex strings , first are decode and then applies algorithm

Rand numbers

Generate 12 bytes with RAND_RP without entropy

{"version":1,"algorithm":"RAND_RP","length":12}

Generate 12 bytes with RAND_RP with entropy using /dev/urandom

{"version":1,"algorithm":"RAND_RP","length":12,"entropy":0}

Generate 12 bytes with RAND_RP with entropy using /dev/random

{"version":1,"algorithm":"RAND_RP","length":12,"entropy":1}

Generate 12 bytes with RAND_RP without entropy

{"version":1,"algorithm":"RAND_RP","length":12,"entropy":2}

  • algorithm: (RAND_RP, RAND_AUTO, RAND_RDRAND)

  • Note: RAND_RDRAND does not need entropy

Argon2

Generate hash password with argon2i from hex string "0123456789ABCDEF" with t_cost, m_cost, parallelism and salt parameters given.

{"algorithm": "ARGON2", "family": "argon2i", "plaintext": "0123456789ABCDEF", "hashlen": 32, "hex": 1, "t_cost": 10, "version": 1, "parallelism": 4, "m_cost": 16, "salt": "ABABABABABABABABABABABABABABABAB", "operation": "hash"}

Generate hash password with argon2i from string "mayhem" with t_cost, m_cost, parallelism and salt parameters given.

{"algorithm": "ARGON2", "family": "argon2i", "plaintext": "mayhem", "hashlen": 32, "hex": 0, "t_cost": 10, "version": 1, "parallelism": 4, "m_cost": 16, "salt": "ABABABABABABABABABABABABABABABAB", "operation": "hash"}

Generate hash password with argon2i from string "mayhem" with t_cost, m_cost, parallelism and salt parameters given.

{"algorithm": "ARGON2", "family": "argon2i", "plaintext": "mayhem", "hashlen": 32, "t_cost": 10, "version": 1, "parallelism": 4, "m_cost": 16, "salt": "ABABABABABABABABABABABABABABABAB", "operation": "hash"}

Verify the hex password "0123456789ABCDEF" with argon2i from pwd given.

{"algorithm": "ARGON2V", "family": "argon2i", "plaintext": "0123456789ABCDEF", "hex": 1, "pwd": "246172676F6E326924763D3139246D3D36353533362C743D31302C703D342451554A42516B464351554A42516B464351554A42516B464351554A42516B464351554A42516B464351554924363276556D62556E2B446D5253385539662F4855656545485262672B4844755631674B4C723956357A3730", "version": 1, "operation": "verify"}

Verify the password "0123456789ABCDEF" with argon2i from pwd given.

{"algorithm": "ARGON2V", "family": "argon2i", "plaintext": "0123456789ABCDEF", "hex": 0, "pwd": "246172676F6E326924763D3139246D3D36353533362C743D31302C703D342451554A42516B464351554A42516B464351554A42516B464351554A42516B464351554A42516B464351554924363276556D62556E2B446D5253385539662F4855656545485262672B4844755631674B4C723956357A3730", "version": 1, "operation": "verify"}

Verify the password "0123456789ABCDEF" with argon2i from pwd given.

{"algorithm": "ARGON2V", "family": "argon2i", "plaintext": "0123456789ABCDEF", "pwd": "246172676F6E326924763D3139246D3D36353533362C743D31302C703D342451554A42516B464351554A42516B464351554A42516B464351554A42516B464351554A42516B464351554924363276556D62556E2B446D5253385539662F4855656545485262672B4844755631674B4C723956357A3730", "version": 1, "operation": "verify"}

  • family: (argon2i, argon2d, argon2id)

  • Note 1: plaintext hex strings , first are decode and then applies algorithm

POLY1305

Calculate POLY1305 to hex string "616263" with the key and nonce given.

{"version":1,"algorithm":"POLY1305","type":"string","plaintext":"616263","hex":1,"key":"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF","nonce":"0123456789ABCDEF0123456789ABCDEF"}

Calculate POLY1305 to string "abc" with the key and nonce given.

{"version":1,"algorithm":"POLY1305","type":"string","plaintext":"abc","hex":0,"key":"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF","nonce":"0123456789ABCDEF0123456789ABCDEF"}

Calculate POLY1305 to string "abc" with the key and nonce given.

{"version":1,"algorithm":"POLY1305","type":"string","plaintext":"abc","key":"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF","nonce":"0123456789ABCDEF0123456789ABCDEF"}

Calculate POLY1305 to file "file_test/AB.mayhem" with the key and nonce given.

{"version":1,"algorithm":"POLY1305","type":"file","file":"file_test/AB.mayhem","key":"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF","nonce":"0123456789ABCDEF0123456789ABCDEF"}

  • Note 1: plaintext hex strings , first are decode and then applies algorithm

  • Note 2: key, nonce are hex strings

HMAC

Calculate HMAC-SHA3_512 to hex string "616263" with the key given.

{"version":1,"algorithm":"HMAC","type":"string","plaintext":"616263","hex":1,"key":"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF","family":"sha3_512"}

Calculate HMAC-SHA3_512 to string "abc" with the key given

{"version":1,"algorithm":"HMAC","type":"string","plaintext":"abc","hex":0,"key":"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF","family":"sha3_512"}

Calculate HMAC-SHA3_512 to string "abc" with the key given

{"version":1,"algorithm":"HMAC","type":"string","plaintext":"abc","key":"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF","family":"sha3_512"}

Calculate HMAC-SHA3_512 to file "file_test/AB.mayhem" with the key given

{"version":1,"algorithm":"HMAC","type":"file","file":"file_test/AB.mayhem","key":"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF","family":"sha3_512"}

  • family: (SHA3_512, SHA3_384, SHA3_256, SHA3_224, SHA_512, SHA_384, SHA_256, SHA_224, SHA_1 ,WHIRLPOOL)

  • Note 1: plaintext hex strings , first are decode and then applies algorithm

  • Note 2: key is hex string

CMAC

Calculate CMAC-AES to hex string "616263" with the key given

{"version":1,"algorithm":"CMAC","type":"string","plaintext":"616263","hex":1,"key":"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" ,"family":"aes"}

Calculate CMAC-AES to string "abc" with the key given

{"version":1,"algorithm":"CMAC","type":"string","plaintext":"abc","hex":0,"key":"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF","family":"aes"}

Calculate CMAC-AES to string "abc" with the key given

{"version":1,"algorithm":"CMAC","type":"string","plaintext":"abc","key":"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF","family":"aes"}

Calculate CMAC-AES to file "file_test/AB.mayhem" with the key given

{"version":1,"algorithm":"CMAC","type":"file","file":"file_test/AB.mayhem","key":"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF","family":"aes"}

  • family: ("aes", "rc6", "mars","serpent","twofish', "cast256")

  • Note 1: plaintext hex strings , first are decode and then applies algorithm

  • Note 2: key is hex string

VMAC

Calculate CMAC-AES to hex string "616263" with the key and iv given

{"version":1,"algorithm":"VMAC","type":"string","plaintext":"616263","hex":1,"key":"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF","iv":"0123456789ABCDEF0123456789ABCDEF","family":"aes"}

Calculate CMAC-AES to string "abc" with the key and iv given

{"version":1,"algorithm":"VMAC","type":"string","plaintext":"abc","hex":0,"key":"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF","iv":"0123456789ABCDEF0123456789ABCDEF","family":"aes"}

Calculate CMAC-AES to string "abc" with the key and iv given

{"version":1,"algorithm":"VMAC","type":"string","plaintext":"abc","key":"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF","iv":"0123456789ABCDEF0123456789ABCDEF","family":"aes"}

Calculate CMAC-AES to file "file_test/AB.mayhem" with the key and iv given

{"version":1,"algorithm":"VMAC","type":"file","file":"file_test/AB.mayhem","key":"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF","iv":"0123456789ABCDEF0123456789ABCDEF","family":"aes"}

  • family: ("aes", "rc6", "mars","serpent","twofish', "cast256")

  • Note 1: plaintext hex strings , first are decode and then applies algorithm

  • Note 2: key,iv are hex strings

Stream

Encrypt with sosemanuk the hex string "616263" with the key and iv given.

{"algorithm":"SOSEMANUK","plaintext":"616263","hex":1,"iv":"b05691ef92cb9c9bf77e5613819fc4ea","version":1,"key":"7f685ba92789f0d8d421038f2b1b4fcd73be586d81795ec3ab7939975b7b896e","operation":"enc","type":"string"}

Decrypt with sosemanuk the hex string "2F99C7" with the key and iv given.

{"algorithm":"SOSEMANUK","plaintext":"2F99C7","hex":1,"iv":"b05691ef92cb9c9bf77e5613819fc4ea","version":1,"key":"7f685ba92789f0d8d421038f2b1b4fcd73be586d81795ec3ab7939975b7b896e","operation":"dec","type":"string"}

Encrypt with sosemanuk the string "Hello world" with the key and iv given.

{"algorithm": "SOSEMANUK", "plaintext": "Hello world", "hex": 0, "iv": "fdd48f4c3e7b38d8340d843af4ee4105", "version": 1, "key":"5845b90c901e1e23155fee366aad083c843d86d3bbff5203821bdc1fc44870b6", "operation": "enc", "type": "string"}

Decrypt with sosemanuk the hex string "0B38620DDAE1B83B036DC9" with the key and iv given.

{"algorithm": "SOSEMANUK", "plaintext": "0B38620DDAE1B83B036DC9", "hex": 0, "iv": "fdd48f4c3e7b38d8340d843af4ee4105", "version": 1, "key":"5845b90c901e1e23155fee366aad083c843d86d3bbff5203821bdc1fc44870b6", "operation": "dec", "type": "string"}

Encrypt with sosemanuk the string "Hello world" with the key and iv given.

{"algorithm": "SOSEMANUK", "plaintext": "Hello world", "iv": "cf29562a250732c6c126d28e903f1ab2", "version": 1, "key": "bcd3db7c5c17bfa7d937748f97dd11e7f84247c6c62c27afeca2ee9c19d79703", "operation": "enc", "type": "string"}

Decrypt with sosemanuk the hex string "0B38620DDAE1B83B036DC9" with the key and iv given.

{"algorithm": "SOSEMANUK", "plaintext": "A27EA0F6A1CA0649938D38", "iv": "cf29562a250732c6c126d28e903f1ab2", "version": 1, "key": "bcd3db7c5c17bfa7d937748f97dd11e7f84247c6c62c27afeca2ee9c19d79703", "operation": "dec", "type": "string"}

Encrypt with sosemanuk the file "file_test/AB.mayhem" with the key and iv given.

{"file": "file_test/AB.mayhem", "algorithm": "SOSEMANUK", "iv": "b7b6c3b588d06bc8f3d0eb48918dfd36", "version": 1,"key": "3ff44eca6261be2276ff25a54039eac8418f26750233018c2692f9c98e4ef53b", "operation": "enc", "type": "file"}

Decrypt with sosemanuk the file "file_test/AB.mayhem.enc" with the key and iv given.

{"file": "file_test/AB.mayhem.enc", "algorithm": "SOSEMANUK", "iv": "b7b6c3b588d06bc8f3d0eb48918dfd36", "version": 1, "key": "3ff44eca6261be2276ff25a54039eac8418f26750233018c2692f9c98e4ef53b", "operation": "dec", "type": "file"}

  • algorithm: ("SOSEMANUK", "SALSA20")

  • Note 1: plaintext hex strings , first are decode and then applies algorithm

  • Note 2: key,iv are hex strings

  • Note 3: For string decryption the plaintext is hex

  • Note 4: For file encryption output is the name file + ".enc"

  • Note 5: For file decryption output is the name file + ".dec"

  • Note 6: Salsa20 uses 8 bit iv

Block

Encrypt with AES the hex string "616263" with the key and iv given in mode ctr.

{"algorithm": "AES", "plaintext": "616263", "hex": 1, "iv": "d58b541118f4aef2c942eb79e57228ee", "version": 1, "mode": "ctr", "key": "1f24df90ae90e8e79eca3f25c120c6c1c68be4c5efced419441c042f6324c683", "operation": "enc", "type": "string"}

Decrypt with AES the hex string "001901" with the key and iv given in mode ctr.

{"algorithm": "AES", "plaintext": "001901", "hex": 1, "iv": "d58b541118f4aef2c942eb79e57228ee", "version": 1, "mode": "ctr", "key": "1f24df90ae90e8e79eca3f25c120c6c1c68be4c5efced419441c042f6324c683", "operation": "dec", "type": "string"}

Encrypt with AES the hex string "616263" with the key,iv and adata given in mode gcm.

{"algorithm": "AES", "plaintext": "616263", "type": "string", "hex": 1, "iv": "1f8478e7e528c1d6e2792d7a40e7d47b", "version": 1, "mode": "gcm", "key": "df2fa695c6c61097a1add5324de12fb4780c6597aefd9d69db46324bf856dea0", "operation": "enc", "adata": "ea52426dc92300c85378457ee39354e6b3410181b18a2247"}

Decrypt with AES the hex string "7516B097C5C7E423FEA2EE3BC3D7C042C93B62" with the key,iv and adata given in mode gcm.

{"algorithm": "AES", "plaintext": "7516B097C5C7E423FEA2EE3BC3D7C042C93B62", "type": "string", "hex": 1, "iv": "1f8478e7e528c1d6e2792d7a40e7d47b", "version": 1, "mode": "gcm", "key": "df2fa695c6c61097a1add5324de12fb4780c6597aefd9d69db46324bf856dea0", "operation": "dec", "adata": "ea52426dc92300c85378457ee39354e6b3410181b18a2247"}

Encrypt with AES the string "Hello world" with the key and iv given in mode ctr.

{"algorithm": "AES", "plaintext": "Hello world", "hex": 0, "iv": "fe016a5cd69fe3d65e04b16dc3b9a57b", "version": 1, "mode": "ctr", "key": "b47d58c182e1ea2049846465840a7b608b2bcee645f544544fda8adf79d701da", "operation": "enc", "type": "string"}

Decrypt with AES the hex string "47B1604AB5C410AEA759C8" with the key and iv given in mode ctr.

{"algorithm": "AES", "plaintext": "47B1604AB5C410AEA759C8", "hex": 0, "iv": "fe016a5cd69fe3d65e04b16dc3b9a57b", "version": 1, "mode": "ctr", "key": "b47d58c182e1ea2049846465840a7b608b2bcee645f544544fda8adf79d701da", "operation": "dec", "type": "string"}

Encrypt with AES the string "Hello world" with the key,iv and adata given in mode gcm.

{"algorithm": "AES", "plaintext": "Hello world", "type": "string", "hex": 0, "iv": "38f0f10ed74f1a3aec2e871ee7d55bb7", "version": 1, "mode": "gcm", "key": "806b622117af9774439dd13744b227dcd3ca0caaed5374baba6da1f6c61cf85c", "operation": "enc", "adata": "dc300f92ed1d255e329c84f782ef87a410fdd74176389366"}

Decrypt with AES the hex string "9A54E2B0885CE5A3FED43FA8014DB36404AE3875BB6FD8F2C557B1" with the key,iv and adata given in mode gcm.

{"algorithm": "AES", "plaintext": "9A54E2B0885CE5A3FED43FA8014DB36404AE3875BB6FD8F2C557B1", "type": "string", "hex": 0, "iv": "38f0f10ed74f1a3aec2e871ee7d55bb7", "version": 1, "mode": "gcm", "key": "806b622117af9774439dd13744b227dcd3ca0caaed5374baba6da1f6c61cf85c", "operation": "dec", "adata": "dc300f92ed1d255e329c84f782ef87a410fdd74176389366"}

Encrypt with AES the string "Hello world" with the key and iv given in mode ctr.

{"algorithm": "AES", "plaintext": "Hello world", "iv": "3315aa2791b1967616e3bbf366043678", "version": 1, "mode": "ctr", "key": "69bf227b55e69ae3bf1f35570f6e8899a279b0b26c8c808f573ab15cbe66dd5b", "operation": "enc", "type": "string"}

Decrypt with AES the hex string "307A69CDFA5C630F7D8AF4" with the key and iv given in mode ctr.

{"algorithm": "AES", "plaintext": "307A69CDFA5C630F7D8AF4", "iv": "3315aa2791b1967616e3bbf366043678", "version": 1, "mode": "ctr", "key": "69bf227b55e69ae3bf1f35570f6e8899a279b0b26c8c808f573ab15cbe66dd5b", "operation": "dec", "type": "string"}

Encrypt with AES the string "Hello world" with the key,iv and adata given in mode gcm.

{"algorithm": "AES", "plaintext": "Hello world", "type": "string", "iv": "e685a62a303585f11fbd2b30a37fe6c7", "version": 1, "mode": "gcm", "key": "d07f8a8d4f6269b99cdfa8951a5d1714ca3cfead3ae9deeccde3ecdcac27ed2e", "operation": "enc", "adata": "cd18dbb63a27adaaf45d00bf3fe5d0c656a77c2b00d8d211"}

Decrypt with AES the hex string "151BF8439C7F544B641851DF99F39C2545FB3DF4A98122ECBF0660" with the key,iv and adata given in mode gcm.

{"algorithm": "AES", "plaintext": "151BF8439C7F544B641851DF99F39C2545FB3DF4A98122ECBF0660", "type": "string", "iv": "e685a62a303585f11fbd2b30a37fe6c7", "version": 1, "mode": "gcm", "key": "d07f8a8d4f6269b99cdfa8951a5d1714ca3cfead3ae9deeccde3ecdcac27ed2e", "operation": "dec", "adata": "cd18dbb63a27adaaf45d00bf3fe5d0c656a77c2b00d8d211"}

Encrypt with AES the file "file_test/AB.mayhem" with the key and iv given in mode ctr.

{"file": "file_test/AB.mayhem", "algorithm": "AES", "iv": "82a8b44118d54f924b3b680b432b972e", "version": 1, "mode": "ctr", "key": "40475638b970df800b61a67308a9d3a1c3b7793987ea6399a1319334aa66042a", "operation": "enc", "type": "file"}

Decrypt with AES the file "file_test/AB.mayhem.enc" with the key and iv given in mode ctr.

{"file": "file_test/AB.mayhem.enc", "algorithm": "AES", "plaintext": "file_test/AB.mayhem.enc", "iv": "82a8b44118d54f924b3b680b432b972e", "version": 1, "mode": "ctr", "key": "40475638b970df800b61a67308a9d3a1c3b7793987ea6399a1319334aa66042a", "operation": "dec", "type": "file"}

  • algorithm: ("AES","RC6","MARS","SERPENT","TWOFISH","CAST256")

  • Note 1: plaintext hex strings , first are decode and then applies algorithm

  • Note 2: key,iv are hex strings

  • Note 3: For string decryption the plaintext is hex

  • Note 4: For file encryption output is the name file + ".enc"

  • Note 5: For file decryption output is the name file + ".dec"

  • Note 6: GCM mode does not support file encryption

RSA

Generate 1024 RSA key pair

{"operation": "gen", "version": 1, "length": 1024, "algorithm": "RSA"}

Sign the string "Hello world" with privkey given

{"algorithm": "RSA", "plaintext": "Hello world", "hex": 0, "version": 1, "operation": "sign", "type": "string", "privkey": "30820274020100300D06092A864886F70D01010105000482025E3082025A0201000281810094A9246782C6986E8AC545B98D4D4888FF0B222F67E5F933A1093512ED8CB933DD7C54D35FE544A22DAFF880F8F1D104443CDC68631374C7A3766A6D2F66635F21C884C5ABAAA2BB5B00FAB4E97DB85C87D862A9FD739967F6772B68BDF7AEF54DC0B2A602559ECCBEA59B49596A423FC2284E37558E1D4678C65ADEEFFE0F7302011102818002EA37EDF381625C853B157211D456C16E69A14C3940BE9C9EC3F1FB59FDBD5B5EB21FC7E8C84299C4A918F378550E23388DBE0C160566AE94C6162A4C393929FE081D0103CE32DE61308047B4269E5443B97C535D82E5C71499F70B701C4B093891E5C52E417ED1B0E8C96E91BC915EBB002EDE956238E0F9EADD0BA0122D01024100C26F438EE0ABC2C6CEF15FF471065910E49537E09B81BAFC5DD62E7F57CE8A07CC17334F4287E9B7D960893195E1E9E3A6558C9BDC39042CE34FD1F7A08A16B9024100C3BB7A0308EABDA72F660C7794C5D482254F662DC0DE17C27DF4C5A2108632173C98B90E88C1714EA6E4F110BAF7627CDAC96B43B6C3C447CBAC7F966BD5018B024100893F7AFB716A2F22EC6E259D7CF56C0BECA590DAC81F56D0423CD58710CE0714901060742EF686DC20F8D9502D9068DCEDE208E67D556C5BEBBFDF819E7F979102405C1BFD2E9AC8D1B8164E23FC09C6821F209DD5BB2D95B0D3FF09C66A6221088367CF6624F50FBCD9B7F344441BBFB5E066F55FA76510D4D67DF6D2A123AF8841024022A68F1978CB85DBF4EDEDE030339CE9A995425D0B89FEB57E65BB694DD7304EC83883C4F7228E664501A4966EF5EA66B468277FE16E7E1C8C20B4B39AEB2C6F"}

Verify the digital signature of string "Hello world" with pubkey given

{"algorithm": "RSA", "plaintext": "Hello world", "pubkey": "30819D300D06092A864886F70D010101050003818B003081870281810094A9246782C6986E8AC545B98D4D4888FF0B222F67E5F933A1093512ED8CB933DD7C54D35FE544A22DAFF880F8F1D104443CDC68631374C7A3766A6D2F66635F21C884C5ABAAA2BB5B00FAB4E97DB85C87D862A9FD739967F6772B68BDF7AEF54DC0B2A602559ECCBEA59B49596A423FC2284E37558E1D4678C65ADEEFFE0F73020111", "hex": 0, "sign": "1A400315E7132A3E15FCE6814D17454FB3F9E6A2035296C7D57BB63E5A39BE8F5B1FCCD8653D038B46B32265658B31289C205620B75E88EBD95CA1E0E30FD78B60271878BE279ED3C56FE855DA8FB327B453FEF5136BDDAF36932DAC5C0C08E678B49D518060F862D2A1960B100B94B5AF81E787004F7CDB4D6BCF63246904F5", "version": 1, "operation": "verify", "type": "string"}

Encrypt the string "hello world!!!" with pubkey given

{"algorithm": "RSA", "plaintext": "hello world!!!", "type": "string", "version": 1, "operation": "enc", "pubkey": "30819D300D06092A864886F70D010101050003818B003081870281810094A9246782C6986E8AC545B98D4D4888FF0B222F67E5F933A1093512ED8CB933DD7C54D35FE544A22DAFF880F8F1D104443CDC68631374C7A3766A6D2F66635F21C884C5ABAAA2BB5B00FAB4E97DB85C87D862A9FD739967F6772B68BDF7AEF54DC0B2A602559ECCBEA59B49596A423FC2284E37558E1D4678C65ADEEFFE0F73020111"}

Decrypt the plaintext given with the privkey given

{"algorithm": "RSA", "plaintext": "82E215088FC28DD580B35906367BFF7992A9F13034DAEEA14D2CDE9C2A539758AFD63A2B160E5C7D9700D81EE630A5D574DC1802152FE7405CD86D7A58FF0E3353C32B0DF48DAF9BCF721EF438C5405E941AE05ACA5DA732B06FFE11903158B66E5333DA57CCBCF2015B0E1C64AF5E006355B9F8D89901829B88962B2C2C7EE6", "type": "string", "version": 1, "operation": "dec", "privkey": "30820274020100300D06092A864886F70D01010105000482025E3082025A0201000281810094A9246782C6986E8AC545B98D4D4888FF0B222F67E5F933A1093512ED8CB933DD7C54D35FE544A22DAFF880F8F1D104443CDC68631374C7A3766A6D2F66635F21C884C5ABAAA2BB5B00FAB4E97DB85C87D862A9FD739967F6772B68BDF7AEF54DC0B2A602559ECCBEA59B49596A423FC2284E37558E1D4678C65ADEEFFE0F7302011102818002EA37EDF381625C853B157211D456C16E69A14C3940BE9C9EC3F1FB59FDBD5B5EB21FC7E8C84299C4A918F378550E23388DBE0C160566AE94C6162A4C393929FE081D0103CE32DE61308047B4269E5443B97C535D82E5C71499F70B701C4B093891E5C52E417ED1B0E8C96E91BC915EBB002EDE956238E0F9EADD0BA0122D01024100C26F438EE0ABC2C6CEF15FF471065910E49537E09B81BAFC5DD62E7F57CE8A07CC17334F4287E9B7D960893195E1E9E3A6558C9BDC39042CE34FD1F7A08A16B9024100C3BB7A0308EABDA72F660C7794C5D482254F662DC0DE17C27DF4C5A2108632173C98B90E88C1714EA6E4F110BAF7627CDAC96B43B6C3C447CBAC7F966BD5018B024100893F7AFB716A2F22EC6E259D7CF56C0BECA590DAC81F56D0423CD58710CE0714901060742EF686DC20F8D9502D9068DCEDE208E67D556C5BEBBFDF819E7F979102405C1BFD2E9AC8D1B8164E23FC09C6821F209DD5BB2D95B0D3FF09C66A6221088367CF6624F50FBCD9B7F344441BBFB5E066F55FA76510D4D67DF6D2A123AF8841024022A68F1978CB85DBF4EDEDE030339CE9A995425D0B89FEB57E65BB694DD7304EC83883C4F7228E664501A4966EF5EA66B468277FE16E7E1C8C20B4B39AEB2C6F"}

Sign the file "file_test/AB.mayhem" with privkey given

{"algorithm": "RSA", "file": "file_test/AB.mayhem", "version": 1, "operation": "sign", "type": "file", "privkey": "30820274020100300D06092A864886F70D01010105000482025E3082025A0201000281810094A9246782C6986E8AC545B98D4D4888FF0B222F67E5F933A1093512ED8CB933DD7C54D35FE544A22DAFF880F8F1D104443CDC68631374C7A3766A6D2F66635F21C884C5ABAAA2BB5B00FAB4E97DB85C87D862A9FD739967F6772B68BDF7AEF54DC0B2A602559ECCBEA59B49596A423FC2284E37558E1D4678C65ADEEFFE0F7302011102818002EA37EDF381625C853B157211D456C16E69A14C3940BE9C9EC3F1FB59FDBD5B5EB21FC7E8C84299C4A918F378550E23388DBE0C160566AE94C6162A4C393929FE081D0103CE32DE61308047B4269E5443B97C535D82E5C71499F70B701C4B093891E5C52E417ED1B0E8C96E91BC915EBB002EDE956238E0F9EADD0BA0122D01024100C26F438EE0ABC2C6CEF15FF471065910E49537E09B81BAFC5DD62E7F57CE8A07CC17334F4287E9B7D960893195E1E9E3A6558C9BDC39042CE34FD1F7A08A16B9024100C3BB7A0308EABDA72F660C7794C5D482254F662DC0DE17C27DF4C5A2108632173C98B90E88C1714EA6E4F110BAF7627CDAC96B43B6C3C447CBAC7F966BD5018B024100893F7AFB716A2F22EC6E259D7CF56C0BECA590DAC81F56D0423CD58710CE0714901060742EF686DC20F8D9502D9068DCEDE208E67D556C5BEBBFDF819E7F979102405C1BFD2E9AC8D1B8164E23FC09C6821F209DD5BB2D95B0D3FF09C66A6221088367CF6624F50FBCD9B7F344441BBFB5E066F55FA76510D4D67DF6D2A123AF8841024022A68F1978CB85DBF4EDEDE030339CE9A995425D0B89FEB57E65BB694DD7304EC83883C4F7228E664501A4966EF5EA66B468277FE16E7E1C8C20B4B39AEB2C6F"}

Verify the digital signature of file "file_test/AB.mayhem.signed" with pubkey given

{"algorithm": "RSA", "file": "file_test/AB.mayhem.signed", "pubkey": "30819D300D06092A864886F70D010101050003818B003081870281810094A9246782C6986E8AC545B98D4D4888FF0B222F67E5F933A1093512ED8CB933DD7C54D35FE544A22DAFF880F8F1D104443CDC68631374C7A3766A6D2F66635F21C884C5ABAAA2BB5B00FAB4E97DB85C87D862A9FD739967F6772B68BDF7AEF54DC0B2A602559ECCBEA59B49596A423FC2284E37558E1D4678C65ADEEFFE0F73020111", "version": 1, "operation": "verify", "type": "string"}

Be careful, when you sign a document the output is file name + "sign", in this case file_test/AB.mayhem.sign, to verify you need to concatenate.

cat file_test/AB.mayhem file_test/AB.mayhem.sign > file_test/AB.mayhem.signed
  • Note 1: plaintext hex strings , first are decode and then applies algorithm

  • Note 2: keys are hex strings

  • Note 3: For string decryption the plaintext is hex

  • Note 4: hex parameter is optional 0 indicate string is not hex and 1 indicate string is hex, default 0.

  • Note 5: RSA does not support file encryption

DSA

Generate 1024 DSA key pair

{"operation": "gen", "version": 1, "length": 1024, "algorithm": "DSA"}

Sign the string "Hello world" with privkey given

{"algorithm": "DSA", "plaintext": "Hello world", "hex": 0, "length": 1024, "version": 1, "operation": "sign", "type": "string", "privkey": "3082014B0201003082012C06072A8648CE3804013082011F02818100F132CDA3C884F877C25556188AFE6BEF185B9EA13ED451D406F5CFAC2AAE04C3F003F500268FF64C8A73607E30BF8125451A7DF36041503EC6EBE643924573BFF7F45080E1DC13D9676648F91EF6FBFD504ABF91C5E3E5A0C5A9044290FA605748B87358E8E80FD489603A85E96D2F37C6AEE2C3BA9AE22DBDEB6F8DC5BA4A070215008AF380C12622501A0EFD7B95D20ADB1FA9EA1D1702818100EFF2D0B9972CE675CA8E0F6C87C75B18EB5888EC830CDCD32AFDAF23724757D0F22EF2653AFBEFB4B61C8773A52C687804268C303BAF2DB672A3F489AFAADC6D3BEF15E0F06E872211FA84FF5D13BBD96CD57387E5AE217FE1070EADB99ECE0DC7462872E9B7DCBDE054A653B9F64D9D02D80153EDD374624EADC4B20C1F1025041602146CF7EB67929A6616F193DB23A1D1AE8C8FF69D3B"}

Verify the digital signature of string "Hello world" with pubkey given

{"algorithm": "DSA", "plaintext": "Hello world", "pubkey": "308201B83082012C06072A8648CE3804013082011F02818100F132CDA3C884F877C25556188AFE6BEF185B9EA13ED451D406F5CFAC2AAE04C3F003F500268FF64C8A73607E30BF8125451A7DF36041503EC6EBE643924573BFF7F45080E1DC13D9676648F91EF6FBFD504ABF91C5E3E5A0C5A9044290FA605748B87358E8E80FD489603A85E96D2F37C6AEE2C3BA9AE22DBDEB6F8DC5BA4A070215008AF380C12622501A0EFD7B95D20ADB1FA9EA1D1702818100EFF2D0B9972CE675CA8E0F6C87C75B18EB5888EC830CDCD32AFDAF23724757D0F22EF2653AFBEFB4B61C8773A52C687804268C303BAF2DB672A3F489AFAADC6D3BEF15E0F06E872211FA84FF5D13BBD96CD57387E5AE217FE1070EADB99ECE0DC7462872E9B7DCBDE054A653B9F64D9D02D80153EDD374624EADC4B20C1F102503818500028181009ED34DF0E1734BE7E2105A283CA6059995BA05207E51DD0EEA68B8E71933419EEBD35ABD6EC9B3C18D3B74707E0C1B644ABBDFE76631E3770AF5823640528CE8935127227E6F7789BBAA1A9727C63186A618BB7634C9052C6F4A61336F6D72AB5B59FBE7CA75ECA7C262DF19E34B40F7841138FE213A81F0A1FA827C5844C2A0", "hex": 0, "sign": "442870692F838F579A906197DF147D2BE8CB42B2131B264407DC992905328AD442D21BAB2C4355A8", "version": 1, "operation": "verify", "type": "string"}

  • Note 1: plaintext hex strings , first are decode and then applies algorithm

  • Note 2: keys are hex strings

  • Note 3: For string decryption the plaintext is hex

  • Note 4: hex parameter is optional 0 indicate string is not hex and 1 indicate string is hex, default 0.

  • Note 5: to sign file is the same like RSA

  • Note 6: key length are 1024, 2048 and 3096

DH

Generate a 1024 custom DH key

{"length": 1024, "version": 1, "operation": "gen_n_rfc", "algorithm": "DH"}

Generate custom DH key with g,q,p and a shared-key with g,q,p,sharedpub given

{"algorithm": "DH", "g": "0x2h", "q": "0x4c43a35765a7da1fba0703df93501de469f791c840d741ace94cae79e2207c17c683b61355abab933a4d1deaabe2809e64a77d85c5654c4962379ce516f7d19283d9b000c200549a2bf06e83252a911614e9a5e794c103b06cf0f41db28dc69527ed3054fce6ebc892bd7473c3a1a421e35d4295cd793593803e625042881847h", "p": "0x988746aecb4fb43f740e07bf26a03bc8d3ef239081ae8359d2995cf3c440f82f8d076c26ab575726749a3bd557c5013cc94efb0b8aca9892c46f39ca2defa32507b360018400a93457e0dd064a55222c29d34bcf29820760d9e1e83b651b8d2a4fda60a9f9cdd791257ae8e787434843c6ba852b9af26b27007cc4a08510308fh", "version": 1, "operation": "a_n_rfc_gen", "sharedpub": "42010BCFA20D232268A967B006C852A2ADAB05AA27CE1EFEB2807E1FB37343B9993EE18B47A5D50B897954F995BE5B24DBC95C28050BDB916DCBF90FE46DCD5D802CF51BB68F736204642614D6FA7D1E6F98A07FD295929F65A0B2F8777491DCFA616DFE012C4C7CBBF6219715BE2BD98DD0BDFC2C5D9EC9750713B5806A59E6"}

Generate a shared-key with g,q,p,sharedpub given

{"algorithm": "DH", "g": "0x2h", "q": "0x4c43a35765a7da1fba0703df93501de469f791c840d741ace94cae79e2207c17c683b61355abab933a4d1deaabe2809e64a77d85c5654c4962379ce516f7d19283d9b000c200549a2bf06e83252a911614e9a5e794c103b06cf0f41db28dc69527ed3054fce6ebc892bd7473c3a1a421e35d4295cd793593803e625042881847h", "p": "0x988746aecb4fb43f740e07bf26a03bc8d3ef239081ae8359d2995cf3c440f82f8d076c26ab575726749a3bd557c5013cc94efb0b8aca9892c46f39ca2defa32507b360018400a93457e0dd064a55222c29d34bcf29820760d9e1e83b651b8d2a4fda60a9f9cdd791257ae8e787434843c6ba852b9af26b27007cc4a08510308fh", "version": 1, "operation": "a_n_rfc", "sharedpub": "5348996122CA5076857506844E2CFD58DC8CB9393478B237D78A2AF3E2CCAF9C6DA8536A133DF050EC95916645D3CBE3AC9EC3805E223B412CC4E8BCFA6ACA5BCCF9AF1D59AC8403BD79C74C586266AC16ABB89027F584C4F9074E5A549E6F6E2F4CC88FA9E3F1752D33FDC1599F71ECB6159F914AC2FC4449076048DDE84D98", "privkey": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000BA849157DD9B15F703A27537F20B62E3C84D8C19"}

Generate a modp256 DH key

{"operation": "gen_rfc", "version": 1, "algorithm": "DH", "family": "modp256"}

Generate a modp256 shared-key with the sharedpub and privkey given

{"algorithm": "DH", "family": "modp256", "version": 1, "operation": "a_rfc", "sharedpub": "6E05A9AC40DD30BB348AC1B7F702E50705273AD8B9EBA41EE74090D76580D72DB1C114501FF11D9B231B3A0253CA95503D12CE74198FCF5014997DE3CBDFCBB95F5364FC89047E4787804D6D375162D69862AD5751BC9BF0CC2799271F54806891D3756E4EAAF8981BFD07767A9B5844672254E1B7D3B46A8901E68F242B0D221287EAC839185B6E36D8FA8618F329840436726A4116D15EC03E4DEACE3017C269E92CD1B1A2ADBE8C1AC517777DA48143043E2A58C7DDF24BACA42804DE2AFD41ECE5029CC1C0CAD78DCEBA4E82ACF2EF8ABF819158A01DD00B6590C20AF799B5D48C1B2399DBC3AA98C17302B49D6508F8D1146C5C78CA2C1BEE6BA4447738", "privkey": "000000011B878B369478626B964DAC6F48FBFE8A1FDAAAD0F2B04B2C76DCDE56"}

ECC

{"version": 1, "curve": "brainpoolP512r1", "algorithm": "ECC_GEN"}

{"algorithm": "ECIES", "plaintext": "hello world!!!", "type": "string", "curve": "secp256k1", "version": 1, "operation": "enc", "pubkey": "3056301006072A8648CE3D020106052B8104000A034200046834B695857EF396C514B4DAFE852DB8C8B5011D64C0B591470127242DFD7FB6A475AF07A02FAC70D36F8B7CE40075FE5E6B5CD0B64FE54255852A311FA7A132"}

{"algorithm": "ECIES", "plaintext": "0474AA7F7642EC769D79B78ACC8F55DF3C8CC2DCA2F175852487FD7D62357A1D743EC0087F26C0DEF109D8E095945FF0F668CD9B55EBCE6E77DF2015445E649D531616E7224D8253703A48810ED9FD9FA00F3E780B4DA295476A4F749B663543B56C54", "type": "string", "curve": "secp256k1", "version": 1, "operation": "dec", "pubkey": "", "privkey": "303E020100301006072A8648CE3D020106052B8104000A042730250201010420C29E12E92DD3125112C62105D3CBF66D403F6950D4BB0900BEC6A284750C5B00"}

{"algorithm": "ECDSA", "plaintext": "Hello world", "curve": "secp256k1", "hex": 0, "version": 1, "operation": "sign", "type": "string", "privkey": "303E020100301006072A8648CE3D020106052B8104000A042730250201010420C29E12E92DD3125112C62105D3CBF66D403F6950D4BB0900BEC6A284750C5B00"}

{"algorithm": "ECDSA", "plaintext": "Hello world", "pubkey": "3056301006072A8648CE3D020106052B8104000A034200046834B695857EF396C514B4DAFE852DB8C8B5011D64C0B591470127242DFD7FB6A475AF07A02FAC70D36F8B7CE40075FE5E6B5CD0B64FE54255852A311FA7A132", "hex": 0, "curve": "secp256k1", "sign": "8B8C833F4712F4939E4AE1339881CE92BA535A39AB1C719A6E383E7163B377DF2DC390DF97362B07E1AC24D31DA98D84F512ED480BABD1D8CCC2D3EC3C371D10", "version": 1, "operation": "verify", "type": "string"}

{"operation": "gen", "version": 1, "curve": "brainpoolP512r1", "algorithm": "ECDH"}

{"algorithm": "ECDH", "family": "", "curve": "brainpoolP512r1", "version": 1, "operation": "agree", "sharedpub": "048A8A4617B3424FC29889E577E6DCDA1472872D97337644EA73D7EB074784FC3A19731A66D5225DFE6F8174E28C79289B863685153C140D5DAABECE8B32D2F2544ADEE9379FA4CB2C5AC21395C3B48045A52BDEFD2971C3B839880EC0154644A213F62D7FCA31DF74BAA2FB9B2A04E302644D137D19DD67E39A1E4A0AFA162F3C", "privkey": "9482034136882455A51772B79E7C13648EB34614F3B09926AA77B5C4342122FA00124D41C57836526EF06153E61E6BBBD06F5B0B8CCFE6CD8F712429CA811B3F"}

  • curve: ("brainpoolP512r1","secp521r1","brainpoolP384r1","secp384r1","brainpoolP320r1","brainpoolP256r1","secp256k1",

    "sect571r1","sect571k1","sect409r1","sect409k1","sect283r1","sect283k1")

  • Note 1: to sign file is the same like RSA

  • Note 2: ECIES does not support file encryption

  • Note 3: ECIES and ECDSA can use the same key, ECDH use its own key

Last updated