Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate sha1_* functions #172

Merged
merged 2 commits into from
Apr 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Migrate sha1 calls to direct use of GChecksum
  • Loading branch information
jelmer committed Feb 3, 2023
commit a4665f2962db9aa8deae4ee6604224f53d31a1e9
13 changes: 6 additions & 7 deletions protocols/jabber/conference.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
\***************************************************************************/

#include "jabber.h"
#include "sha1.h"

static xt_status jabber_chat_join_failed(struct im_connection *ic, struct xt_node *node, struct xt_node *orig);
static xt_status jabber_chat_self_message(struct im_connection *ic, struct xt_node *node, struct xt_node *orig);
Expand Down Expand Up @@ -78,15 +77,15 @@ struct groupchat *jabber_chat_with(struct im_connection *ic, char *who)
struct jabber_data *jd = ic->proto_data;
struct jabber_chat *jc;
struct groupchat *c;
sha1_state_t sum;
GChecksum *sum;
double now = gettime();
char *uuid, *rjid, *cserv;

sha1_init(&sum);
sha1_append(&sum, (uint8_t *) ic->acc->user, strlen(ic->acc->user));
sha1_append(&sum, (uint8_t *) &now, sizeof(now));
sha1_append(&sum, (uint8_t *) who, strlen(who));
uuid = sha1_random_uuid(&sum);
sum = g_checksum_new(G_CHECKSUM_SHA1);
g_checksum_update(sum, (uint8_t *) ic->acc->user, strlen(ic->acc->user));
g_checksum_update(sum, (uint8_t *) &now, sizeof(now));
g_checksum_update(sum, (uint8_t *) who, strlen(who));
uuid = sha1_random_uuid(sum);

if (jd->flags & JFLAG_GTALK) {
cserv = g_strdup("groupchat.google.com");
Expand Down
13 changes: 7 additions & 6 deletions protocols/jabber/iq.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
\***************************************************************************/

#include "jabber.h"
#include "sha1.h"

static xt_status jabber_parse_roster(struct im_connection *ic, struct xt_node *node, struct xt_node *orig);
static xt_status jabber_iq_display_vcard(struct im_connection *ic, struct xt_node *node, struct xt_node *orig);
Expand Down Expand Up @@ -244,15 +243,17 @@ static xt_status jabber_do_iq_auth(struct im_connection *ic, struct xt_node *nod
if (xt_find_node(query->children, "digest") && (s = xt_find_attr(jd->xt->root, "id"))) {
/* We can do digest authentication, it seems, and of
course we prefer that. */
sha1_state_t sha;
GChecksum *sha;
char hash_hex[41];
unsigned char hash[20];
int i;
gsize digest_len = 20;

sha1_init(&sha);
sha1_append(&sha, (unsigned char *) s, strlen(s));
sha1_append(&sha, (unsigned char *) ic->acc->pass, strlen(ic->acc->pass));
sha1_finish(&sha, hash);
sha = g_checksum_new(G_CHECKSUM_SHA1);
g_checksum_update(sha, (unsigned char *) s, strlen(s));
g_checksum_update(sha, (unsigned char *) ic->acc->pass, strlen(ic->acc->pass));
g_checksum_get_digest(sha, hash, &digest_len);
g_checksum_free(sha);

for (i = 0; i < 20; i++) {
sprintf(hash_hex + i * 2, "%02x", hash[i]);
Expand Down
1 change: 0 additions & 1 deletion protocols/jabber/si.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
\***************************************************************************/

#include "jabber.h"
#include "sha1.h"

void jabber_si_answer_request(file_transfer_t *ft);
int jabber_si_send_request(struct im_connection *ic, char *who, struct jabber_transfer *tf);
Expand Down