Skip to content

Commit 0eff505

Browse files
Cleanup the documentation to clarify a few concerns developers addressed (#4468)
1 parent 5b7066f commit 0eff505

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

Firebase/InstanceID/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# 2019-12 -- 4.2.8
22
- [changed] Added heartbeat support for InstanceID (#4323)
3+
- [fixed] Fixed the documentations on a few random generation and hash methods to clarify its use case to avoid confusions. (#4469, #4444, #4326)
34

45
# 2019-11-05 -- 4.2.7
56
- [fixed] Fixed a crash in `checkTokenRefreshPolicyWithIID:` and ensure `tokenWithAuthorizedEntity:scope:options:handler` method is refreshing token if token is not freshed any more. (#4167)

Firebase/InstanceID/FIRInstanceIDCheckinService.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,9 @@ - (NSDictionary *)checkinParametersWithExistingCheckin:
210210
NSInteger userNumber = 0; // Multi Profile may change this.
211211
NSInteger userSerialNumber = 0; // Multi Profile may change this
212212

213+
// This ID is generated for logging purpose and it is only logged for performance
214+
// information for backend, not secure information.
215+
// TODO(chliang): Talk to backend team to see if this ID is still needed.
213216
uint32_t loggingID = arc4random();
214217
NSString *timeZone = [NSTimeZone localTimeZone].name;
215218
int64_t lastCheckingTimestampMillis = checkinPreferences.lastCheckinTimestampMillis;

Firebase/InstanceID/FIRInstanceIDKeyPairUtilities.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@
3030
return [encoding encode:data];
3131
}
3232

33+
// This is NOT used for cryptographic purpose for any encryption or decryption.
34+
// This is solely to generate a random unique string for instanceID.
3335
NSData *FIRInstanceIDSHA1(NSData *data) {
34-
unsigned int outputLength = CC_SHA1_DIGEST_LENGTH;
35-
unsigned char output[outputLength];
36+
unsigned char output[CC_SHA1_DIGEST_LENGTH];
3637
unsigned int length = (unsigned int)[data length];
3738

3839
CC_SHA1(data.bytes, length, output);
39-
return [NSMutableData dataWithBytes:output length:outputLength];
40+
return [NSMutableData dataWithBytes:output length:CC_SHA1_DIGEST_LENGTH];
4041
}
4142

4243
NSDictionary *FIRInstanceIDKeyPairQuery(NSString *tag, BOOL addReturnAttr, BOOL returnData) {
@@ -66,6 +67,7 @@
6667
return nil;
6768
}
6869
NSData *publicKeyData = keyPair.publicKeyData;
70+
// This is used to generate a unique random string, not for encryption/decryption.
6971
NSData *publicKeySHA1 = FIRInstanceIDSHA1(publicKeyData);
7072

7173
const uint8_t *bytes = publicKeySHA1.bytes;

0 commit comments

Comments
 (0)