• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Nonce length issue using libsodium JS

 
Greenhorn
Posts: 4
  • Number of slices to send:
    Optional 'thank-you' note:
I am looking to use Libsodium JS on my site for various cryptographic operations aimed at hiding the actions of my visitors from their ISP or any other passive observer of the network (in addition to the use of an SSL/TLS certificate).

However, I am having difficulty, particularly with the crypto_secretbox_easy() function.
Indeed, when I call this function, I receive an error stating that the length of the nonce is invalid.

Here is my code (or at least code following the same reasoning) :


So, I wanted to see what was wrong. I went directly to the line where the error was triggered, and using the "Sources" tab of the DevTool, I modified the line so that it logs the length of the nonce received and that of the expected nonce.
As expected, the requested length was 24 bytes, but the length received was 32 bytes, regardless of the length of the nonce entered into the function (I tried all numbers between 0 and 7500).

Do you understand anything about it ?
Thank you in advance for your answers.
 
Saloon Keeper
Posts: 15624
366
  • Number of slices to send:
    Optional 'thank-you' note:
Welcome to CodeRanch!

Are you sure that the order in which you pass the nonce and the key to the encryption function is correct?

I'm curious, what's the reason you're not relying on just TLS?
 
Éloi Marchand
Greenhorn
Posts: 4
  • Number of slices to send:
    Optional 'thank-you' note:

Stephan van Hulst wrote:Welcome to CodeRanch!

Are you sure that the order in which you pass the nonce and the key to the encryption function is correct?

I'm curious, what's the reason you're not relying on just TLS?



Thank you for your response and your welcome.

I'm pretty sure I passed the arguments in the right order (otherwise I would have received an error on the type of my arguments), as for the reasons for using the library in addition to the certificate, here they are:

Laws have recently been passed in France, and they will greatly reduce freedom of expression and anonymity online.
My site will include a proxy system in the browser (the idea is to pass traffic from the active tab through the servers hosting my site, they are located in the Russian Federation, and therefore are not restricted in the same way ) as well as end-to-end encrypted messaging.

In order to ensure the security of messages transmitted and the anonymity of activities carried out, I need to add additional encryption managed by my systems.
This helps avoid an advanced MITM scenario with impersonation of my server.
 
Stephan van Hulst
Saloon Keeper
Posts: 15624
366
  • 1
  • Number of slices to send:
    Optional 'thank-you' note:

Éloi Marchand wrote:I'm pretty sure I passed the arguments in the right order (otherwise I would have received an error on the type of my arguments)


So what's the type of the arguments? Aren't both the nonce and the key just supposed to be byte arrays?

Anyway, I'm relatively certain that you're supposed to pass in the message first, the nonce second, and the key third.
 
Éloi Marchand
Greenhorn
Posts: 4
  • Number of slices to send:
    Optional 'thank-you' note:
Ah... yes, it's not stupid, that would explain the length of 32 bytes...
Thank you for your response, I will think before posting next time
 
Stephan van Hulst
Saloon Keeper
Posts: 15624
366
  • Number of slices to send:
    Optional 'thank-you' note:
No problem.

Oh, another thing. The code you showed us is only being used to try out the library, right? When it's time to write the real thing, you'll not generate both key pairs in the same application?

Can you tell us how you're planning to communicate the public keys between the applications?
 
Éloi Marchand
Greenhorn
Posts: 4
  • 2
  • Number of slices to send:
    Optional 'thank-you' note:
Indeed, the code provided was only there for illustration.

The idea to get the other party's public key is:

- The client generates its key pair and stores it in localStorage
- It sends a clear request to the server including the public key
- The server performs various checks (example: if the client's IP is banned)

If the request is accepted, the server generates an identifier and a key pair, which it stores in a database along with the client's public key; then it returns a response containing the generated identifier and the generated public key. The client will use the key to obtain exchange keys, to encrypt messages and the identifier to identify itself to the server.

If the request is refused, the client will be displayed an error message including the cause of the refusal.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic
vceplus-200-125    | boson-200-125    | training-cissp    | actualtests-cissp    | techexams-cissp    | gratisexams-300-075    | pearsonitcertification-210-260    | examsboost-210-260    | examsforall-210-260    | dumps4free-210-260    | reddit-210-260    | cisexams-352-001    | itexamfox-352-001    | passguaranteed-352-001    | passeasily-352-001    | freeccnastudyguide-200-120    | gocertify-200-120    | passcerty-200-120    | certifyguide-70-980    | dumpscollection-70-980    | examcollection-70-534    | cbtnuggets-210-065    | examfiles-400-051    | passitdump-400-051    | pearsonitcertification-70-462    | anderseide-70-347    | thomas-70-533    | research-1V0-605    | topix-102-400    | certdepot-EX200    | pearsonit-640-916    | itproguru-70-533    | reddit-100-105    | channel9-70-346    | anderseide-70-346    | theiia-IIA-CIA-PART3    | certificationHP-hp0-s41    | pearsonitcertification-640-916    | anderMicrosoft-70-534    | cathMicrosoft-70-462    | examcollection-cca-500    | techexams-gcih    | mslearn-70-346    | measureup-70-486    | pass4sure-hp0-s41    | iiba-640-916    | itsecurity-sscp    | cbtnuggets-300-320    | blogged-70-486    | pass4sure-IIA-CIA-PART1    | cbtnuggets-100-101    | developerhandbook-70-486    | lpicisco-101    | mylearn-1V0-605    | tomsitpro-cism    | gnosis-101    | channel9Mic-70-534    | ipass-IIA-CIA-PART1    | forcerts-70-417    | tests-sy0-401    | ipasstheciaexam-IIA-CIA-PART3    | mostcisco-300-135    | buildazure-70-533    | cloudera-cca-500    | pdf4cert-2v0-621    | f5cisco-101    | gocertify-1z0-062    | quora-640-916    | micrcosoft-70-480    | brain2pass-70-417    | examcompass-sy0-401    | global-EX200    | iassc-ICGB    | vceplus-300-115    | quizlet-810-403    | cbtnuggets-70-697    | educationOracle-1Z0-434    | channel9-70-534    | officialcerts-400-051    | examsboost-IIA-CIA-PART1    | networktut-300-135    | teststarter-300-206    | pluralsight-70-486    | coding-70-486    | freeccna-100-101    | digitaltut-300-101    | iiba-CBAP    | virtuallymikebrown-640-916    | isaca-cism    | whizlabs-pmp    | techexams-70-980    | ciscopress-300-115    | techtarget-cism    | pearsonitcertification-300-070    | testking-2v0-621    | isacaNew-cism    | simplilearn-pmi-rmp    | simplilearn-pmp    | educationOracle-1z0-809    | education-1z0-809    | teachertube-1Z0-434    | villanovau-CBAP    | quora-300-206    | certifyguide-300-208    | cbtnuggets-100-105    | flydumps-70-417    | gratisexams-1V0-605    | ituonline-1z0-062    | techexams-cas-002    | simplilearn-70-534    | pluralsight-70-697    | theiia-IIA-CIA-PART1    | itexamtips-400-051    | pearsonitcertification-EX200    | pluralsight-70-480    | learn-hp0-s42    | giac-gpen    | mindhub-102-400    | coursesmsu-CBAP    | examsforall-2v0-621    | developerhandbook-70-487    | root-EX200    | coderanch-1z0-809    | getfreedumps-1z0-062    | comptia-cas-002    | quora-1z0-809    | boson-300-135    | killtest-2v0-621    | learncia-IIA-CIA-PART3    | computer-gcih    | universitycloudera-cca-500    | itexamrun-70-410    | certificationHPv2-hp0-s41    | certskills-100-105    | skipitnow-70-417    | gocertify-sy0-401    | prep4sure-70-417    | simplilearn-cisa    |
http://www.pmsas.pr.gov.br/wp-content/    | http://www.pmsas.pr.gov.br/wp-content/    |