説明なし

FIRInstanceIDKeyPair.m 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 "FIRInstanceIDKeyPair.h"
  17. #import <Security/Security.h>
  18. #import "FIRInstanceIDKeyPairUtilities.h"
  19. #import "FIRInstanceIDKeychain.h"
  20. #import "FIRInstanceIDLogger.h"
  21. #import "NSError+FIRInstanceID.h"
  22. @interface FIRInstanceIDKeyPair () {
  23. SecKeyRef _privateKey;
  24. SecKeyRef _publicKey;
  25. }
  26. @property(nonatomic, readwrite, strong) NSData *publicKeyData;
  27. @property(nonatomic, readwrite, strong) NSData *privateKeyData;
  28. @end
  29. @implementation FIRInstanceIDKeyPair
  30. - (instancetype)initWithPrivateKey:(SecKeyRef)privateKey
  31. publicKey:(SecKeyRef)publicKey
  32. publicKeyData:(NSData *)publicKeyData
  33. privateKeyData:(NSData *)privateKeyData {
  34. self = [super init];
  35. if (self) {
  36. _privateKey = privateKey;
  37. _publicKey = publicKey;
  38. _publicKeyData = publicKeyData;
  39. _privateKeyData = privateKeyData;
  40. }
  41. return self;
  42. }
  43. - (void)dealloc {
  44. if (_privateKey) {
  45. CFRelease(_privateKey);
  46. }
  47. if (_publicKey) {
  48. CFRelease(_publicKey);
  49. }
  50. }
  51. #pragma mark - Info
  52. - (BOOL)isValid {
  53. return _privateKey != NULL && _publicKey != NULL;
  54. }
  55. - (SecKeyRef)publicKey {
  56. return _publicKey;
  57. }
  58. - (SecKeyRef)privateKey {
  59. return _privateKey;
  60. }
  61. @end