示例#1
0
文件: Twitter.cpp 项目: 0x27/mrw-code
void
Twitter::compute_authorization(const char *message)
{
  char *cp = buffer;

  /* Compute key and init HMAC. */

  cp = url_encode_pgm(buffer, consumer_secret);
  *cp++ = '&';

  if (access_token_pgm)
    cp = url_encode_pgm(cp, token_secret.pgm);
  else
    cp = url_encode_eeprom(cp, token_secret.eeprom);

  Sha1.initHmac((uint8_t *) buffer, cp - buffer);

  auth_add_pgm(PSTR("POST&http%3A%2F%2F"));
  auth_add_pgm(server);

  url_encode_pgm(buffer, uri);
  auth_add(buffer);

  auth_add('&');

  auth_add_pgm(PSTR("oauth_consumer_key"));
  auth_add_value_separator();
  url_encode_pgm(buffer, consumer_key);
  auth_add(buffer);

  cp = hex_encode(buffer, nonce, sizeof(nonce));

  auth_add_param(PSTR("oauth_nonce"), buffer, cp + 1);

  auth_add_param(PSTR("oauth_signature_method"), "HMAC-SHA1", buffer);

  sprintf(buffer, "%ld", timestamp);
  auth_add_param(PSTR("oauth_timestamp"), buffer, cp + 1);

  auth_add_param_separator();

  auth_add_pgm(PSTR("oauth_token"));
  auth_add_value_separator();
  if (access_token_pgm)
    url_encode_pgm(buffer, access_token.pgm);
  else
    url_encode_eeprom(buffer, access_token.eeprom);
  auth_add(buffer);

  auth_add_param(PSTR("oauth_version"), "1.0", buffer);

  cp = url_encode(buffer, message);
  auth_add_param(PSTR("status"), buffer, cp + 1);

  signature = Sha1.resultHmac();
}
示例#2
0
文件: Twitter.cpp 项目: 0x27/mrw-code
void
Twitter::auth_add_param(const prog_char key[], const char *value, char *workbuf)
{
  /* Add separator.  We know that this method is not used to add the
     first parameter. */
  auth_add_param_separator();

  auth_add_pgm(key);

  auth_add_value_separator();

  url_encode(workbuf, value);
  auth_add(workbuf);
}
示例#3
0
static void c_add_auth(char *v1, char *v2, void *t)
{
#ifdef USE_AUTH
    auth_add(v1,v2);
#endif
}