Forum Stats

  • 3,875,057 Users
  • 2,266,799 Discussions
  • 7,912,070 Comments

Discussions

Function for RSA SHA-256 digital signature

124»

Answers

  • AntonScheffer-Oracle
    AntonScheffer-Oracle Posts: 20 Employee
    edited Aug 15, 2022 3:19PM

    In case you did not found the solution. Your sign parameter is wrong. You should base64 decode the third part of the JWT. So use something like this:

    declare
      function base64URL_decode( p_txt varchar2 )
      return raw
      is
      begin
        return utl_encode.base64_decode( utl_raw.cast_to_raw( translate( p_txt, '-_', '+/' ) ) ); 
      end;
    begin
     if as_crypto.verify ( src   => utl_raw.cast_to_raw ( 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlhdCI6MTUxNjIzOTAyMn0')
               , sign   => base64URL_decode( 'NHVaYe26MbtOYhSKkoKYdFVomg4i8ZJd8_-RU8VNbftc4TSMb4bXP3l3YlNWACwyXPGffz5aXHc6lty1Y2t4SWRqGteragsVdZufDn5BlnJl9pdR_kdVFUsra2rWKEofkZeIC4yWytE58sMIihvo9H1ScmmVwBcQP6XETqYd0aSHp1gOa9RdUPDvoXQ5oqygTqVtxaDr6wUFKrKItgBMzWIdNZ6y7O9E0DhEPTbE9rfBo6KTFsHAZnMg4k68CDp2woYIaXbmYTWcvbzIuHO7_37GT79XdIwkm95QJ7hYC9RiwrV7mesbY4PAahERJawntho0my942XheVLmGwLMBkQ')
               , pub_key => utl_raw.cast_to_raw ( '-----BEGIN PUBLIC KEY-----
    MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAu1SU1LfVLPHCozMxH2Mo
    4lgOEePzNm0tRgeLezV6ffAt0gunVTLw7onLRnrq0/IzW7yWR7QkrmBL7jTKEn5u
    +qKhbwKfBstIs+bMY2Zkp18gnTxKLxoS2tFczGkPLPgizskuemMghRniWaoLcyeh
    kd3qqGElvW/VDL5AaWTg0nLVkjRo9z+40RQzuVaE8AkAFmxZzow3x+VJYKdjykkJ
    0iT9wCS0DRTXu269V264Vf/3jvredZiKRkgwlL9xNAwxXFg0x/XFw005UWVRIkdg
    cKWTjpBP2dPwVZ4WWC+9aGVd+Gyn1o0CLelf4rEjGoXbAAEgAqeGUxrcIlbjXfbc
    mwIDAQAB
    -----END PUBLIC KEY-----' )
              , pubkey_alg => as_crypto.KEY_TYPE_RSA
              , sign_alg  => as_crypto.SIGN_SHA256_RSA )
     then
      dbms_output.put_line ('Verified');
     else
      dbms_output.put_line ('Failed verification');
     end if ;
    end ;
    

    P.S. Using pubkey_alg => as_crypto.KEY_TYPE_EC and sign_alg => as_crypto.SIGN_SHA256withECDSAinP1363 you can use as_crypto for the JWT "alg": "ES256"

  • User_XC37T
    User_XC37T Member Posts: 1 Green Ribbon
    edited Nov 7, 2022 9:03AM

    Thank you @AntonScheffer-Oracle, I was able to integrate Apex with DocuSign successfully on 19C. Your comments on this discussion thread were really very helpful.