Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Threema/ThreemaFramework/Utilities/   (Social Medium ©)  Datei vom 26.9.2026 mit Größe 929 B image not shown  

Quelle  NonceHasher.m  Sprache: unbekannt

 
Spracherkennung für: .m vermutete Sprache: Abap {ABAP[55] Delphi[54] Lisp[52]} [Methode: maximale Elemente, drei Dimensionen]

#import "NonceHasher.h"
#import "CryptoUtils.h"

#ifdef DEBUG
static const DDLogLevel ddLogLevel = DDLogLevelVerbose;
#else
static const DDLogLevel ddLogLevel = DDLogLevelNotice;
#endif

@implementation NonceHasher

+ (NSData *)hashedNonce:(NSData *)nonce myIdentity:(nullable NSString *)myIdentity {
    /* Hash nonce with HMAC-SHA256 using the identity as the key if available.
       This serves to make it impossible to correlate the nonce DBs of users to determine whether they have been communicating. */

    NSData *identity = [myIdentity dataUsingEncoding:NSASCIIStringEncoding];
    if (identity == nil) {
        // This should never be called
        DDLogError(@"Nonces should only be processed if my identity exists");
        NSAssert(false, @"Nonces should only be processed if my identity exists");
        return nil;
    } else {
        return [CryptoUtils hmacSha256ForData:nonce key:identity];
    }
}

@end

[Dauer der Verarbeitung: 0.9 Sekunden]