2
$\begingroup$

The Stanford JS Crypto Library appears to be trusted by many people. Unfortunately there isn't a lot of documentation. Their encrypt function is documented as a "simple encryption function" (that's it). The default values in the source code look like it's AES-128? Are there any restrictions on input, like length, special characters, etc?

$\endgroup$
1
  • 1
    $\begingroup$ Where do you base your claims that it is "trusted by many people"? Their github page has 38commits and 44issues..? Also, if their library is any good, there are no restrictions that you will face before you exhaust all ram for encryption input. $\endgroup$
    – axapaxa
    Dec 4 '16 at 22:07
4
$\begingroup$

The SJCL demo page suggests that what it's doing is symmetric-key authenticated encryption using either the CCM or the OCB2 mode. The cipher used appears to be AES, not that that matters much. (Any other secure block cipher with similar block and key sizes would work just as well.)

Actually peeking into the code reveals that there's more to it than that. For example, for the encryption key, it can apparently accept either a password string (which will be hashed using PBKDF2 to derive the actual key), an ECC ElGamal public key (used to generate and encapsulate a random symmetric encryption key) or, presumably, a raw AES key in the library's internal format.

In any case, besides the demo, the sparse auto-generated documentation, and the code itself, I have not been able to find any proper documentation or specification for this library. While at a glance the design of the library seems sound enough, and while the author list includes Dan Boneh, who certainly seems a reputable and competent enough cryptographer, I still would not recommend using this library given its lack of documentation.

Simply put, even if the library itself worked perfectly and did exactly what it was supposed to, without proper documentation you simply have no way to tell (short of reviewing the whole source code yourself) whether you're using it correctly and securely or not. Given that most crypto failures in practice arise from putting the right parts together in the wrong way, that's a glaring flaw in my book.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.