View | Details | Raw Unified | Return to bug 228940
Collapse All | Expand All

(-)sync.c (-20 / +22 lines)
Lines 439-445 Link Here
439
	u_int16_t sglen, fromlen, tolen, helolen, padlen;
439
	u_int16_t sglen, fromlen, tolen, helolen, padlen;
440
	char pad[SPAM_ALIGNBYTES];
440
	char pad[SPAM_ALIGNBYTES];
441
	int i = 0;
441
	int i = 0;
442
	HMAC_CTX ctx;
442
	HMAC_CTX* ctx;
443
	u_int hmac_len;
443
	u_int hmac_len;
444
444
445
	if (debug)
445
	if (debug)
Lines 455-462 Link Here
455
	tolen = strlen(to) + 1;
455
	tolen = strlen(to) + 1;
456
	helolen = strlen(helo) + 1;
456
	helolen = strlen(helo) + 1;
457
457
458
	HMAC_CTX_init(&ctx);
458
	ctx = HMAC_CTX_new();
459
	HMAC_Init(&ctx, sync_key, strlen(sync_key), EVP_sha1());
459
	HMAC_CTX_reset(ctx);
460
	HMAC_Init_ex(ctx, sync_key, strlen(sync_key), EVP_sha1(), NULL);
460
461
461
	sglen = sizeof(sg) + fromlen + tolen + helolen;
462
	sglen = sizeof(sg) + fromlen + tolen + helolen;
462
	padlen = SPAM_ALIGN(sglen) - sglen;
463
	padlen = SPAM_ALIGN(sglen) - sglen;
Lines 468-474 Link Here
468
	hdr.sh_length = htons(sizeof(hdr) + sglen + padlen + sizeof(end));
469
	hdr.sh_length = htons(sizeof(hdr) + sglen + padlen + sizeof(end));
469
	iov[i].iov_base = &hdr;
470
	iov[i].iov_base = &hdr;
470
	iov[i].iov_len = sizeof(hdr);
471
	iov[i].iov_len = sizeof(hdr);
471
	HMAC_Update(&ctx, iov[i].iov_base, iov[i].iov_len);
472
	HMAC_Update(ctx, iov[i].iov_base, iov[i].iov_len);
472
	i++;
473
	i++;
473
474
474
	/* Add single SPAM sync greylisting entry */
475
	/* Add single SPAM sync greylisting entry */
Lines 481-507 Link Here
481
	sg.sg_helo_length = htons(helolen);
482
	sg.sg_helo_length = htons(helolen);
482
	iov[i].iov_base = &sg;
483
	iov[i].iov_base = &sg;
483
	iov[i].iov_len = sizeof(sg);
484
	iov[i].iov_len = sizeof(sg);
484
	HMAC_Update(&ctx, iov[i].iov_base, iov[i].iov_len);
485
	HMAC_Update(ctx, iov[i].iov_base, iov[i].iov_len);
485
	i++;
486
	i++;
486
487
487
	iov[i].iov_base = from;
488
	iov[i].iov_base = from;
488
	iov[i].iov_len = fromlen;
489
	iov[i].iov_len = fromlen;
489
	HMAC_Update(&ctx, iov[i].iov_base, iov[i].iov_len);
490
	HMAC_Update(ctx, iov[i].iov_base, iov[i].iov_len);
490
	i++;
491
	i++;
491
492
492
	iov[i].iov_base = to;
493
	iov[i].iov_base = to;
493
	iov[i].iov_len = tolen;
494
	iov[i].iov_len = tolen;
494
	HMAC_Update(&ctx, iov[i].iov_base, iov[i].iov_len);
495
	HMAC_Update(ctx, iov[i].iov_base, iov[i].iov_len);
495
	i++;
496
	i++;
496
497
497
	iov[i].iov_base = helo;
498
	iov[i].iov_base = helo;
498
	iov[i].iov_len = helolen;
499
	iov[i].iov_len = helolen;
499
	HMAC_Update(&ctx, iov[i].iov_base, iov[i].iov_len);
500
	HMAC_Update(ctx, iov[i].iov_base, iov[i].iov_len);
500
	i++;
501
	i++;
501
502
502
	iov[i].iov_base = pad;
503
	iov[i].iov_base = pad;
503
	iov[i].iov_len = padlen;
504
	iov[i].iov_len = padlen;
504
	HMAC_Update(&ctx, iov[i].iov_base, iov[i].iov_len);
505
	HMAC_Update(ctx, iov[i].iov_base, iov[i].iov_len);
505
	i++;
506
	i++;
506
507
507
	/* Add end marker */
508
	/* Add end marker */
Lines 509-522 Link Here
509
	end.st_length = htons(sizeof(end));
510
	end.st_length = htons(sizeof(end));
510
	iov[i].iov_base = &end;
511
	iov[i].iov_base = &end;
511
	iov[i].iov_len = sizeof(end);
512
	iov[i].iov_len = sizeof(end);
512
	HMAC_Update(&ctx, iov[i].iov_base, iov[i].iov_len);
513
	HMAC_Update(ctx, iov[i].iov_base, iov[i].iov_len);
513
	i++;
514
	i++;
514
515
515
	HMAC_Final(&ctx, hdr.sh_hmac, &hmac_len);
516
	HMAC_Final(ctx, hdr.sh_hmac, &hmac_len);
516
517
517
	/* Send message to the target hosts */
518
	/* Send message to the target hosts */
518
	sync_send(iov, i);
519
	sync_send(iov, i);
519
	HMAC_CTX_cleanup(&ctx);
520
	HMAC_CTX_free(ctx);
520
}
521
}
521
522
522
void
523
void
Lines 527-533 Link Here
527
	struct spam_synctlv_addr sd;
528
	struct spam_synctlv_addr sd;
528
	struct spam_synctlv_hdr end;
529
	struct spam_synctlv_hdr end;
529
	int i = 0;
530
	int i = 0;
530
	HMAC_CTX ctx;
531
	HMAC_CTX* ctx;
531
	u_int hmac_len;
532
	u_int hmac_len;
532
533
533
	if (debug)
534
	if (debug)
Lines 537-544 Link Here
537
	bzero(&hdr, sizeof(hdr));
538
	bzero(&hdr, sizeof(hdr));
538
	bzero(&sd, sizeof(sd));
539
	bzero(&sd, sizeof(sd));
539
540
540
	HMAC_CTX_init(&ctx);
541
	ctx = HMAC_CTX_new();
541
	HMAC_Init(&ctx, sync_key, strlen(sync_key), EVP_sha1());
542
	HMAC_CTX_reset(ctx);
543
	HMAC_Init_ex(ctx, sync_key, strlen(sync_key), EVP_sha1(), NULL);
542
544
543
	/* Add SPAM sync packet header */
545
	/* Add SPAM sync packet header */
544
	hdr.sh_version = SPAM_SYNC_VERSION;
546
	hdr.sh_version = SPAM_SYNC_VERSION;
Lines 547-553 Link Here
547
	hdr.sh_length = htons(sizeof(hdr) + sizeof(sd) + sizeof(end));
549
	hdr.sh_length = htons(sizeof(hdr) + sizeof(sd) + sizeof(end));
548
	iov[i].iov_base = &hdr;
550
	iov[i].iov_base = &hdr;
549
	iov[i].iov_len = sizeof(hdr);
551
	iov[i].iov_len = sizeof(hdr);
550
	HMAC_Update(&ctx, iov[i].iov_base, iov[i].iov_len);
552
	HMAC_Update(ctx, iov[i].iov_base, iov[i].iov_len);
551
	i++;
553
	i++;
552
554
553
	/* Add single SPAM sync address entry */
555
	/* Add single SPAM sync address entry */
Lines 558-564 Link Here
558
	sd.sd_ip = inet_addr(ip);
560
	sd.sd_ip = inet_addr(ip);
559
	iov[i].iov_base = &sd;
561
	iov[i].iov_base = &sd;
560
	iov[i].iov_len = sizeof(sd);
562
	iov[i].iov_len = sizeof(sd);
561
	HMAC_Update(&ctx, iov[i].iov_base, iov[i].iov_len);
563
	HMAC_Update(ctx, iov[i].iov_base, iov[i].iov_len);
562
	i++;
564
	i++;
563
565
564
	/* Add end marker */
566
	/* Add end marker */
Lines 566-579 Link Here
566
	end.st_length = htons(sizeof(end));
568
	end.st_length = htons(sizeof(end));
567
	iov[i].iov_base = &end;
569
	iov[i].iov_base = &end;
568
	iov[i].iov_len = sizeof(end);
570
	iov[i].iov_len = sizeof(end);
569
	HMAC_Update(&ctx, iov[i].iov_base, iov[i].iov_len);
571
	HMAC_Update(ctx, iov[i].iov_base, iov[i].iov_len);
570
	i++;
572
	i++;
571
573
572
	HMAC_Final(&ctx, hdr.sh_hmac, &hmac_len);
574
	HMAC_Final(ctx, hdr.sh_hmac, &hmac_len);
573
575
574
	/* Send message to the target hosts */
576
	/* Send message to the target hosts */
575
	sync_send(iov, i);
577
	sync_send(iov, i);
576
	HMAC_CTX_cleanup(&ctx);
578
	HMAC_CTX_free(ctx);
577
}
579
}
578
580
579
void
581
void

Return to bug 228940