Pkcs padding

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Pkcs padding

Max Lapshin-2

I was writing to ask for help, but found the solution myself,

Google widevine (DRM system) ( ) requires signing JSON request.

Have spent half a day on "bad argument" from crypto library, but found that I was not making padding for crypto.

The C++ code has:

Crypt(base::SHA1HashString(message), signature)

where Crypt has following:

    AES_cbc_encrypt(plaintext, ciphertext, cbc_size, aes_key(),
          , AES_ENCRYPT);

I could make it work with such code:

Pkcs = fun(A,N) -> Pad = N - (size(A) rem N), <<A/binary, (binary:copy(<<Pad>>, Pad))/binary>> end,

The trick is to add standard padding that makes content proper size.

erlang-questions mailing list
[hidden email]