Difference between revisions of "Component: Hydro Encryption (Comms: Networking)"

From Flowcode Help
Jump to navigationJump to search
(Created page with "{| style="width:50%" |- | width="20%" style="color:gray;" | Author | |- | width="20%" style="color:gray;" | Version | 1.0 |- | width="20%" style="color:gray;" | Categ...")
 
 
(9 intermediate revisions by the same user not shown)
Line 17: Line 17:
 
==Component Source Code==
 
==Component Source Code==
  
Please click here for the component source code: [https://www.flowcode.co.uk/wikicopy/componentsource/FC_Comp_Source_libhydrogen.fcfx FC_Comp_Source_libhydrogen.fcfx]
+
Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_libhydrogen.fcfx FC_Comp_Source_libhydrogen.fcfx]
 +
 
 +
Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_libhydrogen.fcfx FC_Comp_Source_libhydrogen.fcfx]
  
 
==Detailed description==
 
==Detailed description==
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
  
 
''No detailed description exists yet for this component''
 
''No detailed description exists yet for this component''
  
 
==Examples==
 
==Examples==
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
  
 
''<span style="color:red;">No additional examples</span>''
 
''<span style="color:red;">No additional examples</span>''
  
==Downloadable macro reference==
 
  
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''sign_create'''
 
|-
 
| colspan="2" | Computes a signature for a message using the secret key. Returns 0 if successful.&nbsp;
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" | signature
 
|-
 
| colspan="2" | Buffer to receive the signature. Must be 64 bytes.&nbsp;
 
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" | message
 
|-
 
| colspan="2" | Buffer containing the data to sign&nbsp;
 
|-
 
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 
| width="90%" | message_size
 
|-
 
| colspan="2" | Byte count of the message&nbsp;
 
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" | secret_key
 
|-
 
| colspan="2" | Secret/Private key to be used.Size is 64 bytes.&nbsp;
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-s16-icon.png]] - INT
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
  
  
 +
 +
 +
 +
 +
 +
 +
 +
==Macro reference==
 +
 +
===hash_keygen===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''secretbox_keygen'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''hash_keygen'''
 
|-
 
|-
| colspan="2" | Creates a secret key suitable for use with the secretbox functions. You must provide a 32 byte array for the key.&nbsp;
+
| colspan="2" | Creates a secret key suitable for use with the hash_hash function. You must provide a 32 byte array for the key.&nbsp;
 
|-
 
|-
 
|-
 
|-
Line 80: Line 84:
  
  
 +
===hash_with_key===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
Line 113: Line 118:
  
  
 +
===hash_without_key===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''sign_verify'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''hash_without_key'''
 
|-
 
|-
| colspan="2" | Verify the signature of a mesasge using the public key. Returns 0 if successful.&nbsp;
+
| colspan="2" | Creates a hash fingerprint of the data, which will always have the same fingerprint, similar to the MD5 or SHA-1 Returns 0 if successful.&nbsp;
 
|-
 
|-
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | signature
+
| width="90%" | hash
 
|-
 
|-
| colspan="2" | Buffer to receive the signature. Must be 64 bytes.&nbsp;
+
| colspan="2" | Buffer for the hash. Size >=32 makes it practically impossible for two messages to produce the same fingerprint.&nbsp;
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | message
+
| width="90%" | data
 
|-
 
|-
| colspan="2" | Buffer containing the data to sign&nbsp;
+
| colspan="2" | Data buffer to be processed&nbsp;
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | message_size
+
| width="90%" | size
 
|-
 
|-
| colspan="2" | Byte count of the message&nbsp;
+
| colspan="2" | Byte count of data to be processed&nbsp;
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" | public_key
 
|-
 
| colspan="2" | Public key to be used.Size is 32 bytes.&nbsp;
 
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-s16-icon.png]] - INT
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-s16-icon.png]] - INT
Line 146: Line 147:
  
  
 +
===init===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
Line 159: Line 161:
  
  
 +
===secretbox_decrypt===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''sign_keygen'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''secretbox_decrypt'''
 +
|-
 +
| colspan="2" | Decrypts a message with a secret key. A single key is used both to encrypt/sign and verify/decrypt messages. For this reason, it is critical to keep the key confidential. Returns 0 on success.&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | message
 +
|-
 +
| colspan="2" | Buffer for the decrypted message. Size must be at least length - 36&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" | length
 +
|-
 +
| colspan="2" | The length (byte count) of the ciphertext&nbsp;
 
|-
 
|-
| colspan="2" | Creates Private and Public key pair to sign and verify messages. Returns 0 if successful.&nbsp;
+
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" | ID
 
|-
 
|-
 +
| colspan="2" | Message ID. Must match with the original message ID. Can be 0&nbsp;
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Secret
+
| width="90%" | key
 
|-
 
|-
| colspan="2" | Buffer to receive the Private/Secret Key. Buffer size must be 64 bytes&nbsp;
+
| colspan="2" | The secret key&nbsp;
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Public
+
| width="90%" | ciphertext
 
|-
 
|-
| colspan="2" | Buffer to receive the Public key. Buffer size must be 32 bytes&nbsp;
+
| colspan="2" | Buffer containing the ciphertext to be decrypted.&nbsp;
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-s16-icon.png]] - INT
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-s16-icon.png]] - INT
Line 182: Line 200:
  
  
 +
===secretbox_encrypt===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
Line 220: Line 239:
  
  
 +
===secretbox_keygen===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''hash_keygen'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''secretbox_keygen'''
 
|-
 
|-
| colspan="2" | Creates a secret key suitable for use with the hash_hash function. You must provide a 32 byte array for the key.&nbsp;
+
| colspan="2" | Creates a secret key suitable for use with the secretbox functions. You must provide a 32 byte array for the key.&nbsp;
 
|-
 
|-
 
|-
 
|-
Line 238: Line 258:
  
  
 +
===sign_create===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''secretbox_decrypt'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''sign_create'''
 
|-
 
|-
| colspan="2" | Decrypts a message with a secret key. A single key is used both to encrypt/sign and verify/decrypt messages. For this reason, it is critical to keep the key confidential. Returns 0 on success.&nbsp;
+
| colspan="2" | Computes a signature for a message using the secret key. Returns 0 if successful.&nbsp;
 
|-
 
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | signature
 +
|-
 +
| colspan="2" | Buffer to receive the signature. Must be 64 bytes.&nbsp;
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" | message
 
| width="90%" | message
 
|-
 
|-
| colspan="2" | Buffer for the decrypted message. Size must be at least length - 36&nbsp;
+
| colspan="2" | Buffer containing the data to sign&nbsp;
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | length
+
| width="90%" | message_size
 +
|-
 +
| colspan="2" | Byte count of the message&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | secret_key
 +
|-
 +
| colspan="2" | Secret/Private key to be used.Size is 64 bytes.&nbsp;
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-s16-icon.png]] - INT
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
 +
 
 +
 
 +
===sign_keygen===
 +
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
| colspan="2" | The length (byte count) of the ciphertext&nbsp;
+
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''sign_keygen'''
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
+
| colspan="2" | Creates Private and Public key pair to sign and verify messages. Returns 0 if successful.&nbsp;
| width="90%" | ID
 
 
|-
 
|-
| colspan="2" | Message ID. Must match with the original message ID. Can be 0&nbsp;
 
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | key
+
| width="90%" | Secret
 
|-
 
|-
| colspan="2" | The secret key&nbsp;
+
| colspan="2" | Buffer to receive the Private/Secret Key. Buffer size must be 64 bytes&nbsp;
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | ciphertext
+
| width="90%" | Public
 
|-
 
|-
| colspan="2" | Buffer containing the ciphertext to be decrypted.&nbsp;
+
| colspan="2" | Buffer to receive the Public key. Buffer size must be 32 bytes&nbsp;
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-s16-icon.png]] - INT
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-s16-icon.png]] - INT
Line 276: Line 316:
  
  
 +
===sign_verify===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''hash_without_key'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''sign_verify'''
 
|-
 
|-
| colspan="2" | Creates a hash fingerprint of the data, which will always have the same fingerprint, similar to the MD5 or SHA-1 Returns 0 if successful.&nbsp;
+
| colspan="2" | Verify the signature of a mesasge using the public key. Returns 0 if successful.&nbsp;
 
|-
 
|-
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | hash
+
| width="90%" | signature
 
|-
 
|-
| colspan="2" | Buffer for the hash. Size >=32 makes it practically impossible for two messages to produce the same fingerprint.&nbsp;
+
| colspan="2" | Buffer to receive the signature. Must be 64 bytes.&nbsp;
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | data
+
| width="90%" | message
 
|-
 
|-
| colspan="2" | Data buffer to be processed&nbsp;
+
| colspan="2" | Buffer containing the data to sign&nbsp;
 
|-
 
|-
 
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" | size
+
| width="90%" | message_size
 +
|-
 +
| colspan="2" | Byte count of the message&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | public_key
 
|-
 
|-
| colspan="2" | Byte count of data to be processed&nbsp;
+
| colspan="2" | Public key to be used.Size is 32 bytes.&nbsp;
 
|-
 
|-
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-s16-icon.png]] - INT
 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-s16-icon.png]] - INT
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
|}
 
 
  
  

Latest revision as of 13:13, 7 February 2023

Author
Version 1.0
Category Comms: Networking


Hydro Encryption component

A cipher suite to enable encryption and decryption of data messages, based on libhydrogen.

Component Source Code

Please click here to download the component source project: FC_Comp_Source_libhydrogen.fcfx

Please click here to view the component source code (Beta): FC_Comp_Source_libhydrogen.fcfx

Detailed description

No detailed description exists yet for this component

Examples

No additional examples






Macro reference

hash_keygen

Fc9-comp-macro.png hash_keygen
Creates a secret key suitable for use with the hash_hash function. You must provide a 32 byte array for the key. 
Fc9-u8-icon.png - BYTE key
 
Fc9-void-icon.png - VOID Return


hash_with_key

Fc9-comp-macro.png hash_with_key
Creates a hash fingerprint of the data, using the given key. Returns 0 if successful. 
Fc9-u8-icon.png - BYTE hash
Buffer for the hash. Size >=32 makes it practically impossible for two messages to produce the same fingerprint. 
Fc9-u8-icon.png - BYTE data
The data buffer to be processed 
Fc9-u16-icon.png - UINT size
Byte count of the data to be processed 
Fc9-u8-icon.png - BYTE key
Key to be used 
Fc9-s16-icon.png - INT Return


hash_without_key

Fc9-comp-macro.png hash_without_key
Creates a hash fingerprint of the data, which will always have the same fingerprint, similar to the MD5 or SHA-1 Returns 0 if successful. 
Fc9-u8-icon.png - BYTE hash
Buffer for the hash. Size >=32 makes it practically impossible for two messages to produce the same fingerprint. 
Fc9-u8-icon.png - BYTE data
Data buffer to be processed 
Fc9-u16-icon.png - UINT size
Byte count of data to be processed 
Fc9-s16-icon.png - INT Return


init

Fc9-comp-macro.png init
Initialisation function. To be called at the very start of your program. 
Fc9-s16-icon.png - INT Return


secretbox_decrypt

Fc9-comp-macro.png secretbox_decrypt
Decrypts a message with a secret key. A single key is used both to encrypt/sign and verify/decrypt messages. For this reason, it is critical to keep the key confidential. Returns 0 on success. 
Fc9-u8-icon.png - BYTE message
Buffer for the decrypted message. Size must be at least length - 36 
Fc9-u16-icon.png - UINT length
The length (byte count) of the ciphertext 
Fc9-u16-icon.png - UINT ID
Message ID. Must match with the original message ID. Can be 0 
Fc9-u8-icon.png - BYTE key
The secret key 
Fc9-u8-icon.png - BYTE ciphertext
Buffer containing the ciphertext to be decrypted. 
Fc9-s16-icon.png - INT Return


secretbox_encrypt

Fc9-comp-macro.png secretbox_encrypt
Encrypts a message with a secret key. A single key is used both to encrypt/sign and verify/decrypt messages. For this reason, it is critical to keep the key confidential. Returns 0 on success. 
Fc9-u8-icon.png - BYTE message
Buffer containing the message to be encrypted. 
Fc9-u16-icon.png - UINT length
The length (byte count) of the message 
Fc9-u16-icon.png - UINT ID
Message ID. Can be 0 
Fc9-u8-icon.png - BYTE key
The secret key 
Fc9-u8-icon.png - BYTE ciphertext
Buffer for ciphertext output. Buffer size must be at least length + 36 
Fc9-s16-icon.png - INT Return


secretbox_keygen

Fc9-comp-macro.png secretbox_keygen
Creates a secret key suitable for use with the secretbox functions. You must provide a 32 byte array for the key. 
Fc9-u8-icon.png - BYTE key
 
Fc9-void-icon.png - VOID Return


sign_create

Fc9-comp-macro.png sign_create
Computes a signature for a message using the secret key. Returns 0 if successful. 
Fc9-u8-icon.png - BYTE signature
Buffer to receive the signature. Must be 64 bytes. 
Fc9-u8-icon.png - BYTE message
Buffer containing the data to sign 
Fc9-u16-icon.png - UINT message_size
Byte count of the message 
Fc9-u8-icon.png - BYTE secret_key
Secret/Private key to be used.Size is 64 bytes. 
Fc9-s16-icon.png - INT Return


sign_keygen

Fc9-comp-macro.png sign_keygen
Creates Private and Public key pair to sign and verify messages. Returns 0 if successful. 
Fc9-u8-icon.png - BYTE Secret
Buffer to receive the Private/Secret Key. Buffer size must be 64 bytes 
Fc9-u8-icon.png - BYTE Public
Buffer to receive the Public key. Buffer size must be 32 bytes 
Fc9-s16-icon.png - INT Return


sign_verify

Fc9-comp-macro.png sign_verify
Verify the signature of a mesasge using the public key. Returns 0 if successful. 
Fc9-u8-icon.png - BYTE signature
Buffer to receive the signature. Must be 64 bytes. 
Fc9-u8-icon.png - BYTE message
Buffer containing the data to sign 
Fc9-u16-icon.png - UINT message_size
Byte count of the message 
Fc9-u8-icon.png - BYTE public_key
Public key to be used.Size is 32 bytes. 
Fc9-s16-icon.png - INT Return


Property reference

Fc9-prop-icon.png Properties