Няма описание

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * Copyright 2019 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. @class FIRInstanceIDKeyPair;
  18. extern NSString *const kFIRInstanceIDKeyPairSubType;
  19. @class FIRInstanceIDKeyPairStore;
  20. @interface FIRInstanceIDKeyPairStore : NSObject
  21. /**
  22. * Invalidates the cached keypairs in the Keychain, if needed. The keypair metadata plist is
  23. * checked for existence. If the plist file does not exist, it is a signal of a new installation,
  24. * and therefore the key pairs are not valid.
  25. *
  26. * Returns YES if keypair has been invalidated.
  27. */
  28. - (BOOL)invalidateKeyPairsIfNeeded;
  29. /**
  30. * Delete the cached RSA keypair from Keychain with the given subtype.
  31. *
  32. * @param subtype The subtype used to cache the RSA keypair in Keychain.
  33. * @param handler The callback handler which is invoked when the keypair deletion is
  34. * complete, with an error if there is any.
  35. */
  36. - (void)deleteSavedKeyPairWithSubtype:(NSString *)subtype handler:(void (^)(NSError *))handler;
  37. /**
  38. * Delete the plist that caches KeyPair generation timestamps.
  39. *
  40. * @param error The error if any while deleting the plist else nil.
  41. *
  42. * @return YES if the delete was successful else NO.
  43. */
  44. - (BOOL)removeKeyPairCreationTimePlistWithError:(NSError **)error;
  45. /**
  46. * Loads a cached KeyPair if it exists in the Keychain else generate a new
  47. * one. If a keyPair already exists in memory this will just return that. This should
  48. * not be called from the main thread since it could potentially lead to creating a new
  49. * RSA-2048 bit keyPair which is an expensive operation.
  50. *
  51. * @param error The error, if any, while accessing the Keychain.
  52. *
  53. * @return A valid 2048 bit RSA key pair.
  54. */
  55. - (FIRInstanceIDKeyPair *)loadKeyPairWithError:(NSError **)error;
  56. /**
  57. * Check if the Keychain has any cached keypairs or not.
  58. *
  59. * @return YES if the Keychain has cached RSA KeyPairs else NO.
  60. */
  61. - (BOOL)hasCachedKeyPairs;
  62. /**
  63. * Return an identifier for the app instance. The result is a short identifier that can
  64. * be used as a key when storing information about the app. This method will return the same
  65. * ID as long as the application identity remains active. If the identity has been revoked or
  66. * expired the method will generate and return a new identifier.
  67. *
  68. * @param error The error if any while loading the RSA KeyPair.
  69. *
  70. * @return The identifier, as url safe string.
  71. */
  72. - (NSString *)appIdentityWithError:(NSError *__autoreleasing *)error;
  73. @end