S3 Tools in Bash

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
1
down vote

favorite












This is a follow on to a previous question:



Part 1: Signature



All the code I am submitting here is available in github




The reason to write these tools is so I can prototype and quickly verify that I am doing things correctly before implementing them in C++. This is mainly necessary because the documentation these scripts are based on are relatively bad and confusing.




s3/signature



#!/usr/bin/env bash

check=$(echo -n s3 | openssl dgst -sha256 -binary -mac HMAC -macopt hexkey:01dda345af12 2> /dev/null | xxd -p -c 256)
if [[ "$check" != "6d00e194dca4f102300b638bb3404a1c9b8c1ba73514d22a7013f9832c20366a" ]]; then
echo "Check of openssl failed"
echo "You need a verions greater than 0"
exit 1
fi


#
# method
# url
# key
# secret
# dateTime if empty use now utc
# expires
# service if blank extracts from the URL
# region if blank extracts from the URL
# signHeaders if 1 creates headers for signing otherwise creates query parameters
# verbose if blank (empty or just white space) then no extra output.
# otherwise it is a filename to output (note - represents stdout)
# headers[@]

function createSignature xxd -p -c 256)

#
# Build the String to sign.
local ss=$(cat - <<StringToSign
AWS4-HMAC-SHA256
$dateTime
$date/$region/$service/aws4_request
$HashedCanonicalRequest
StringToSign
)

#
# Calculate the signature
local kDate=$(echo -n $date






share|improve this question

























    up vote
    1
    down vote

    favorite












    This is a follow on to a previous question:



    Part 1: Signature



    All the code I am submitting here is available in github




    The reason to write these tools is so I can prototype and quickly verify that I am doing things correctly before implementing them in C++. This is mainly necessary because the documentation these scripts are based on are relatively bad and confusing.




    s3/signature



    #!/usr/bin/env bash

    check=$(echo -n s3 | openssl dgst -sha256 -binary -mac HMAC -macopt hexkey:01dda345af12 2> /dev/null | xxd -p -c 256)
    if [[ "$check" != "6d00e194dca4f102300b638bb3404a1c9b8c1ba73514d22a7013f9832c20366a" ]]; then
    echo "Check of openssl failed"
    echo "You need a verions greater than 0"
    exit 1
    fi


    #
    # method
    # url
    # key
    # secret
    # dateTime if empty use now utc
    # expires
    # service if blank extracts from the URL
    # region if blank extracts from the URL
    # signHeaders if 1 creates headers for signing otherwise creates query parameters
    # verbose if blank (empty or just white space) then no extra output.
    # otherwise it is a filename to output (note - represents stdout)
    # headers[@]

    function createSignature xxd -p -c 256)

    #
    # Build the String to sign.
    local ss=$(cat - <<StringToSign
    AWS4-HMAC-SHA256
    $dateTime
    $date/$region/$service/aws4_request
    $HashedCanonicalRequest
    StringToSign
    )

    #
    # Calculate the signature
    local kDate=$(echo -n $date






    share|improve this question





















      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      This is a follow on to a previous question:



      Part 1: Signature



      All the code I am submitting here is available in github




      The reason to write these tools is so I can prototype and quickly verify that I am doing things correctly before implementing them in C++. This is mainly necessary because the documentation these scripts are based on are relatively bad and confusing.




      s3/signature



      #!/usr/bin/env bash

      check=$(echo -n s3 | openssl dgst -sha256 -binary -mac HMAC -macopt hexkey:01dda345af12 2> /dev/null | xxd -p -c 256)
      if [[ "$check" != "6d00e194dca4f102300b638bb3404a1c9b8c1ba73514d22a7013f9832c20366a" ]]; then
      echo "Check of openssl failed"
      echo "You need a verions greater than 0"
      exit 1
      fi


      #
      # method
      # url
      # key
      # secret
      # dateTime if empty use now utc
      # expires
      # service if blank extracts from the URL
      # region if blank extracts from the URL
      # signHeaders if 1 creates headers for signing otherwise creates query parameters
      # verbose if blank (empty or just white space) then no extra output.
      # otherwise it is a filename to output (note - represents stdout)
      # headers[@]

      function createSignature xxd -p -c 256)

      #
      # Build the String to sign.
      local ss=$(cat - <<StringToSign
      AWS4-HMAC-SHA256
      $dateTime
      $date/$region/$service/aws4_request
      $HashedCanonicalRequest
      StringToSign
      )

      #
      # Calculate the signature
      local kDate=$(echo -n $date






      share|improve this question











      This is a follow on to a previous question:



      Part 1: Signature



      All the code I am submitting here is available in github




      The reason to write these tools is so I can prototype and quickly verify that I am doing things correctly before implementing them in C++. This is mainly necessary because the documentation these scripts are based on are relatively bad and confusing.




      s3/signature



      #!/usr/bin/env bash

      check=$(echo -n s3 | openssl dgst -sha256 -binary -mac HMAC -macopt hexkey:01dda345af12 2> /dev/null | xxd -p -c 256)
      if [[ "$check" != "6d00e194dca4f102300b638bb3404a1c9b8c1ba73514d22a7013f9832c20366a" ]]; then
      echo "Check of openssl failed"
      echo "You need a verions greater than 0"
      exit 1
      fi


      #
      # method
      # url
      # key
      # secret
      # dateTime if empty use now utc
      # expires
      # service if blank extracts from the URL
      # region if blank extracts from the URL
      # signHeaders if 1 creates headers for signing otherwise creates query parameters
      # verbose if blank (empty or just white space) then no extra output.
      # otherwise it is a filename to output (note - represents stdout)
      # headers[@]

      function createSignature xxd -p -c 256)

      #
      # Build the String to sign.
      local ss=$(cat - <<StringToSign
      AWS4-HMAC-SHA256
      $dateTime
      $date/$region/$service/aws4_request
      $HashedCanonicalRequest
      StringToSign
      )

      #
      # Calculate the signature
      local kDate=$(echo -n $date








      share|improve this question










      share|improve this question




      share|improve this question









      asked Jan 13 at 22:33









      Martin York

      70.9k481244




      70.9k481244

























          active

          oldest

          votes











          Your Answer




          StackExchange.ifUsing("editor", function ()
          return StackExchange.using("mathjaxEditing", function ()
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
          );
          );
          , "mathjax-editing");

          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "196"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );








           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f185066%2fs3-tools-in-bash%23new-answer', 'question_page');

          );

          Post as a guest



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes










           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f185066%2fs3-tools-in-bash%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          Chat program with C++ and SFML

          Function to Return a JSON Like Objects Using VBA Collections and Arrays

          Will my employers contract hold up in court?