Creating Key using HMAC - SHA1 using openSSL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bhavesh.Feb@gmail.com

    Creating Key using HMAC - SHA1 using openSSL

    Hi,
    I'm trying to use SHA1 and HMAC to create signature for my web
    service request. I dont know much about HMAC or SHA1 but this is what i
    need to create signature. What i'm trying to do is:

    SHA_CTX shaContext;
    SHA1_Init(&shaC ontext);
    SHA1_Update(&sh aContext, &data, dataLen );
    SHA1_Final(ciph er_key, &shaContext) ;

    char out[EVP_MAX_MD_SIZE]; // EVP_MAX_MD_SIZE is the limit on
    int len; // what HMAC will ever put in out
    HMAC(
    sha1(),
    secretKey,
    strlen(secretKe y),
    data.c_str(),
    dataLen,
    out,
    &len
    );

    It's throwing some compilation error for call to HMAC as i'm not
    passing correct parameter to it.

    Does someone already implemented this???? Can someone share working
    code snippet?

    Thanks,
    Bhavesh

  • Bhavesh.Feb@gmail.com

    #2
    Re: Creating Key using HMAC - SHA1 using openSSL

    I'm working on unix and am using opneSSL libraries.

    Bhavesh.Feb@gma il.com wrote:
    Hi,
    I'm trying to use SHA1 and HMAC to create signature for my web
    service request. I dont know much about HMAC or SHA1 but this is what i
    need to create signature. What i'm trying to do is:
    >
    SHA_CTX shaContext;
    SHA1_Init(&shaC ontext);
    SHA1_Update(&sh aContext, &data, dataLen );
    SHA1_Final(ciph er_key, &shaContext) ;
    >
    char out[EVP_MAX_MD_SIZE]; // EVP_MAX_MD_SIZE is the limit on
    int len; // what HMAC will ever put in out
    HMAC(
    sha1(),
    secretKey,
    strlen(secretKe y),
    data.c_str(),
    dataLen,
    out,
    &len
    );
    >
    It's throwing some compilation error for call to HMAC as i'm not
    passing correct parameter to it.
    >
    Does someone already implemented this???? Can someone share working
    code snippet?
    >
    Thanks,
    Bhavesh

    Comment

    • David Harmon

      #3
      Re: Creating Key using HMAC - SHA1 using openSSL

      On 22 Sep 2006 14:52:57 -0700 in comp.lang.c++,
      Bhavesh.Feb@gma il.com wrote,
      It's throwing some compilation error for call to HMAC as i'm not
      >passing correct parameter to it.
      No fair asking about an error message without telling us what it
      says!

      Comment

      • red floyd

        #4
        Re: Creating Key using HMAC - SHA1 using openSSL

        David Harmon wrote:
        On 22 Sep 2006 14:52:57 -0700 in comp.lang.c++,
        Bhavesh.Feb@gma il.com wrote,
        > It's throwing some compilation error for call to HMAC as i'm not
        >passing correct parameter to it.
        >
        No fair asking about an error message without telling us what it
        says!
        >
        He has an error on line 42 of his code.

        Comment

        • Thomas J. Gritzan

          #5
          Re: Creating Key using HMAC - SHA1 using openSSL

          Bhavesh.Feb@gma il.com schrieb:
          I'm trying to use SHA1 and HMAC to create signature for my web
          service request. I dont know much about HMAC or SHA1 but this is what i
          need to create signature. What i'm trying to do is:
          >
          SHA_CTX shaContext;
          SHA1_Init(&shaC ontext);
          SHA1_Update(&sh aContext, &data, dataLen );
          SHA1_Final(ciph er_key, &shaContext) ;
          >
          char out[EVP_MAX_MD_SIZE]; // EVP_MAX_MD_SIZE is the limit on
          int len; // what HMAC will ever put in out
          HMAC(
          sha1(),
          secretKey,
          strlen(secretKe y),
          data.c_str(),
          dataLen,
          out,
          &len
          );


          Seems like you pass an int* where an unsigned int* is needed, and char*
          where unsigned char*...
          well, giving us the error messages would help, but asking in a newsgroup
          where this library is on-topic would be even better. Try a unix programming
          newsgroup.

          See here:

          and here:


          --
          Thomas

          Comment

          Working...