Skip to content
Snippets Groups Projects
Commit 1dafd52b authored by Haris Andrianakis's avatar Haris Andrianakis Committed by Tink Team
Browse files

Adding Obj-C default config registration.

PiperOrigin-RevId: 204327044
GitOrigin-RevId: 770ada770bb494b8abb9184b7c5f48d89bb0484a
parent 53a9f826
No related branches found
No related tags found
No related merge requests found
Showing
with 74 additions and 53 deletions
......@@ -27,11 +27,10 @@ NS_ASSUME_NONNULL_BEGIN
* This class is used for registering with the Registry all instances of Aead key types supported in
* a particular release of Tink.
*
* To register all Aead key types provided in Tink release 1.1.0 one can do:
* To register all Aead key types provided in the latest release of Tink one can do:
*
* NSError *error = nil;
* TINKAeadConfig *aeadConfig = [TINKAeadConfig alloc] initWithVersion:TINKVersion1_1_0
* error:&error];
* TINKAeadConfig *aeadConfig = [[TINKAeadConfig alloc] initWithError:&error];
* if (!aeadConfig || error) {
* // handle error.
* }
......@@ -44,10 +43,17 @@ NS_ASSUME_NONNULL_BEGIN
*/
@interface TINKAeadConfig : TINKRegistryConfig
/* Use initWithVersion:error: to get an instance of TINKAeadConfig. */
/* Use -initWithError: to get an instance of TINKAeadConfig. */
- (nullable instancetype)init NS_UNAVAILABLE;
/* Returns config of Aead implementations supported in given @c version of Tink. */
/* Returns config of Aead implementations supported in the latest version of Tink. */
- (nullable instancetype)initWithError:(NSError **)error NS_DESIGNATED_INITIALIZER;
/**
* Returns config of Aead implementations supported in given @c version of Tink.
*
* @warning DEPRECATED: Please use -initWithError:.
*/
- (nullable instancetype)initWithVersion:(TINKVersion)version
error:(NSError **)error NS_DESIGNATED_INITIALIZER;
......
......@@ -30,8 +30,7 @@ NS_ASSUME_NONNULL_BEGIN;
* methods from TINKAeadConfig. Here is an example how one can obtain and use a TINKAead primitive:
*
* NSError *error = nil;
* TINKAeadConfig *aeadConfig = [TINKAeadConfig alloc] initWithVersion:TINKVersion1_1_0
* error:&error];
* TINKAeadConfig *aeadConfig = [[TINKAeadConfig alloc] initWithError:&error];
* if (!aeadConfig || error) {
* // handle error.
* }
......
......@@ -89,8 +89,7 @@ NS_ASSUME_NONNULL_BEGIN
* Example:
*
* NSError *error = nil;
* TINKAeadConfig *aeadConfig = [[TINKAeadConfig alloc] initWithVersion:TINKVersion1_1_0
* error:&error];
* TINKAeadConfig *aeadConfig = [[TINKAeadConfig alloc] initWithError:&error];
* if (!aeadConfig || error) {
* // handle error.
* }
......@@ -99,7 +98,8 @@ NS_ASSUME_NONNULL_BEGIN
* // handle error.
* }
*
* TINKAeadKeyTemplate *tpl = [TINAeadKeyTemplate initWithKeyTemplate:TINKAes128Gcm error:&error];
* TINKAeadKeyTemplate *tpl = [[TINAeadKeyTemplate alloc] initWithKeyTemplate:TINKAes128Gcm
* error:&error];
* if (!tpl || error) {
* // handle error.
* }
......
......@@ -24,12 +24,12 @@
NS_ASSUME_NONNULL_BEGIN
/**
* Static methods for registering with the Registry all instances of Tink key types supported in a
* particular release of Tink. To register all Tink key types provided in Tink release 1.1.0 one can
* do:
* Methods for registering with the Registry all instances of Tink key types supported in a
* particular release of Tink. To register all Tink key types provided in the latest release of Tink
* one can do:
*
* NSError *error = nil;
* TINKAllConfig *allConfig = [[TINKAllConfig alloc] initWithVersion:TINKVersion1_1_0 error:&error];
* TINKAllConfig *allConfig = [[TINKAllConfig alloc] initWithError:&error];
* if (error || !allConfig) {
* // handle error.
* }
......@@ -40,9 +40,17 @@ NS_ASSUME_NONNULL_BEGIN
*/
@interface TINKAllConfig : TINKRegistryConfig
/** Use initWithVersion:error: to get an instance of TINKAllConfig. */
/** Use -initWithError: to get an instance of TINKAllConfig. */
- (nullable instancetype)init NS_UNAVAILABLE;
/** Returns config of all implementations supported in the latest version of Tink. */
- (nullable instancetype)initWithError:(NSError **)error NS_DESIGNATED_INITIALIZER;
/**
* Returns config of all implementations supported in a given @c version of Tink.
*
* @warning DEPRECATED: Please use -initWithError:.
*/
- (nullable instancetype)initWithVersion:(TINKVersion)version
error:(NSError **)error NS_DESIGNATED_INITIALIZER;
......
......@@ -33,7 +33,7 @@ NS_ASSUME_NONNULL_BEGIN
* Example usage:
*
* NSError *error = nil;
* TINKAllConfig *config = [[TINKAllConfig alloc] initWithVersion:TINKVersion1_1_0 error:&error];
* TINKAllConfig *config = [[TINKAllConfig alloc] initWithError:&error];
* if (!config || error) {
* // handle error.
* }
......
......@@ -27,12 +27,10 @@ NS_ASSUME_NONNULL_BEGIN
* This class is used for registering with the Registry all instances of Hybrid key types
* supported in a particular release of Tink.
*
* To register all Hybrid key types provided in Tink release 1.1.0 one can do:
* To register all Hybrid key types provided in the latest release of Tink one can do:
*
* NSError *error = nil;
* TINKHybridConfig *hybridConfig =
* [[TINKHybridConfig alloc] initWithVersion:TINKVersion1_1_0
* error:&error];
* TINKHybridConfig *hybridConfig = [[TINKHybridConfig alloc] initWithError:&error];
* if (!hybridConfig || error) {
* // handle error.
* }
......@@ -49,7 +47,14 @@ NS_ASSUME_NONNULL_BEGIN
/* Use initWithVersion:error: to get an instance of TINKHybridConfig. */
- (nullable instancetype)init NS_UNAVAILABLE;
/* Returns config of Hybrid implementations supported in given @c version of Tink. */
/* Returns config of Hybrid implementations supported in the latest version of Tink. */
- (nullable instancetype)initWithError:(NSError **)error NS_DESIGNATED_INITIALIZER;
/**
* Returns config of Hybrid implementations supported in given @c version of Tink.
*
* @warning DEPRECATED: Please use -initWithError:.
*/
- (nullable instancetype)initWithVersion:(TINKVersion)version
error:(NSError **)error NS_DESIGNATED_INITIALIZER;
......
......@@ -32,8 +32,7 @@ NS_ASSUME_NONNULL_BEGIN
* TINKHybridDecrypt primitive:
*
* NSError *error = nil;
* TINKHybridConfig *hybridConfig =
* [[TINKHybridConfig alloc] initWithVersion:TINKVersion1_1_0 error:&error];
* TINKHybridConfig *hybridConfig = [[TINKHybridConfig alloc] initWithError:&error];
* if (!hybridConfig || error) {
* // handle error.
* }
......
......@@ -32,8 +32,7 @@ NS_ASSUME_NONNULL_BEGIN
* TINKHybridEncrypt primitive:
*
* NSError *error = nil;
* TINKHybridConfig *hybridConfig =
* [[TINKHybridConfig alloc] initWithVersion:TINKVersion1_1_0 error:&error];
* TINKHybridConfig *hybridConfig = [[TINKHybridConfig alloc] initWithError:&error];
* if (!hybridConfig || error) {
* // handle error.
* }
......
......@@ -53,8 +53,7 @@ NS_ASSUME_NONNULL_BEGIN
* Example:
*
* NSError *error = nil;
* TINKHybridConfig *hybridConfig = [[TINKHybridConfig alloc] initWithVersion:TINKVersion1_1_0
* error:&error];
* TINKHybridConfig *hybridConfig = [[TINKHybridConfig alloc] initWithError:&error];
* if (!hybridConfig || error) {
* // handle error.
* }
......
......@@ -27,11 +27,10 @@ NS_ASSUME_NONNULL_BEGIN
* This class is used for registering with the Registry all instances of Mac key types supported in
* a particular release of Tink.
*
* To register all Mac key types provided in Tink release 1.1.0 one can do:
* To register all Mac key types provided in the latest release of Tink one can do:
*
* NSError *error = nil;
* TINKMacConfig *macConfig = [TINKMacConfig alloc] initWithVersion:TINKVersion1_1_0
* error:&error];
* TINKMacConfig *macConfig = [[TINKMacConfig alloc] initWithError:&error];
* if (!macConfig || error) {
* // handle error.
* }
......@@ -44,10 +43,17 @@ NS_ASSUME_NONNULL_BEGIN
*/
@interface TINKMacConfig : TINKRegistryConfig
/* Use initWithVersion:error: to get an instance of TINKMacConfig. */
/* Use -initWithError: to get an instance of TINKMacConfig. */
- (nullable instancetype)init NS_UNAVAILABLE;
/* Returns config of Mac implementations supported in given @c version of Tink. */
/* Returns config of Mac implementations supported in the latest version of Tink. */
- (nullable instancetype)initWithError:(NSError **)error NS_DESIGNATED_INITIALIZER;
/**
* Returns config of Mac implementations supported in given @c version of Tink.
*
* @warning DEPRECATED: Please use -initWithError:.
*/
- (nullable instancetype)initWithVersion:(TINKVersion)version
error:(NSError **)error NS_DESIGNATED_INITIALIZER;
......
......@@ -30,8 +30,7 @@ NS_ASSUME_NONNULL_BEGIN
* methods in TINKMacConfig. Here is an example how one can obtain and use a TINKMac primitive:
*
* NSError *error = nil;
* TINKMacConfig *macConfig = [TINKMacConfig alloc] initWithVersion:TINKVersion1_1_0
* error:&error];
* TINKMacConfig *macConfig = [[TINKMacConfig alloc] initWithError:&error];
* if (!macConfig || error) {
* // handle error.
* }
......
......@@ -49,8 +49,7 @@ NS_ASSUME_NONNULL_BEGIN
* Example:
*
* NSError *error = nil;
* TINKMacConfig *macConfig = [[TINMacConfig alloc] initWithVersion:TINKVersion1_1_0
* error:&error];
* TINKMacConfig *macConfig = [[TINMacConfig alloc] initWithError:&error];
* if (!macConfig || error) {
* // handle error.
* }
......
......@@ -32,9 +32,7 @@ NS_ASSUME_NONNULL_BEGIN;
* use a TINKPublicKeySign primitive:
*
* NSError *error = nil;
* TINKSignatureConfig *signatureConfig = [TINKSignatureConfig alloc]
* initWithVersion:TINKVersion1_1_0
* error:&error];
* TINKSignatureConfig *signatureConfig = [[TINKSignatureConfig alloc] initWithError:&error];
* if (!signatureConfig || error) {
* // handle error.
* }
......
......@@ -32,9 +32,7 @@ NS_ASSUME_NONNULL_BEGIN;
* use a TINKPublicKeyVerify primitive:
*
* NSError *error = nil;
* TINKSignatureConfig *signatureConfig = [TINKSignatureConfig alloc]
* initWithVersion:TINKVersion1_1_0
* error:&error];
* TINKSignatureConfig *signatureConfig = [[TINKSignatureConfig alloc] initWithError:&error];
* if (!signatureConfig || error) {
* // handle error.
* }
......
......@@ -37,6 +37,8 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (nullable instancetype)init NS_UNAVAILABLE;
- (nullable instancetype)initWithError:(NSError **)error NS_DESIGNATED_INITIALIZER;
- (nullable instancetype)initWithVersion:(TINKVersion)version
error:(NSError **)error NS_DESIGNATED_INITIALIZER;
......
......@@ -27,11 +27,10 @@ NS_ASSUME_NONNULL_BEGIN
* This class is used for registering with the Registry all instances of Signautre key types
* supported in a particular release of Tink.
*
* To register all Signature key types provided in Tink release 1.1.0 one can do:
* To register all Signature key types provided in the latest release of Tink one can do:
*
* NSError *error = nil;
* TINKSignatureConfig *config = [TINKSignatureConfig alloc] initWithVersion:TINKVersion1_1_0
* error:&error];
* TINKSignatureConfig *config = [[TINKSignatureConfig alloc] initWithError:&error];
* if (!config || error) {
* // handle error.
* }
......@@ -45,13 +44,20 @@ NS_ASSUME_NONNULL_BEGIN
*/
@interface TINKSignatureConfig : TINKRegistryConfig
/* Use initWithVersion:error: to get an instance of TINKSignatureConfig. */
/* Use -initWithError: to get an instance of TINKSignatureConfig. */
- (nullable instancetype)init NS_UNAVAILABLE;
/* Returns config of Signature implementations supported in given @c version of Tink. */
/**
* Returns config of Signature implementations supported in given @c version of Tink.
*
* @warning DEPRECATED: Please use -initWithError:.
*/
- (nullable instancetype)initWithVersion:(TINKVersion)version
error:(NSError **)error NS_DESIGNATED_INITIALIZER;
/* Returns config of Signature implementations supported in the latest version of Tink. */
- (nullable instancetype)initWithError:(NSError **)error NS_DESIGNATED_INITIALIZER;
@end
NS_ASSUME_NONNULL_END
......@@ -58,8 +58,7 @@ NS_ASSUME_NONNULL_BEGIN
* Example:
*
* NSError *error = nil;
* TINKSignatureConfig *config = [[TINKSignatureConfig alloc] initWithVersion:TINKVersion1_1_0
* error:&error];
* TINKSignatureConfig *config = [[TINKSignatureConfig alloc] initWithError:&error];
* if (!config || error) {
* // handle error.
* }
......
......@@ -20,4 +20,5 @@
typedef NS_ENUM(NSInteger, TINKVersion) {
TINKVersion1_1_0 = 0x110,
TINKVersionLatest = 0xfff,
};
......@@ -40,8 +40,7 @@
std::string hmac_key_type = "type.googleapis.com/google.crypto.tink.HmacKey";
NSError *error = nil;
TINKAeadConfig *aeadConfig =
[[TINKAeadConfig alloc] initWithVersion:TINKVersion1_1_0 error:&error];
TINKAeadConfig *aeadConfig = [[TINKAeadConfig alloc] initWithError:&error];
XCTAssertNotNil(aeadConfig);
XCTAssertNil(error);
......
......@@ -93,8 +93,7 @@ using google::crypto::tink::KeyStatusType;
keyset.set_primary_key_id(key_id_3);
NSError *error = nil;
TINKAeadConfig *aeadConfig =
[[TINKAeadConfig alloc] initWithVersion:TINKVersion1_1_0 error:&error];
TINKAeadConfig *aeadConfig = [[TINKAeadConfig alloc] initWithError:&error];
XCTAssertNotNil(aeadConfig);
XCTAssertNil(error);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment