Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARTCipherParams and ARTCrypto doc comments #1439

Closed
wants to merge 8 commits into from

Conversation

maratal
Copy link
Collaborator

@maratal maratal commented Jun 30, 2022

Added docstrings according to ably/sdk-api-reference#8

Was checked for compatibility with jazzy.

@github-actions github-actions bot temporarily deployed to staging/pull/1439/jazzydoc June 30, 2022 22:42 Inactive
@maratal
Copy link
Collaborator Author

maratal commented Jun 30, 2022

@lawrence-forooghian
Copy link
Collaborator

lawrence-forooghian commented Jul 5, 2022

I've added @m-hulbert as a reviewer here, too, since he might be picking up any necessary changes to the canonical documentation once @tbedford rolls off this project.

@@ -28,13 +28,20 @@ NS_ASSUME_NONNULL_BEGIN
@end

/**
ARTCipherParams contains configuration options for a channel cipher, including algorithm, mode, key length and key.
Ably client libraries currently support AES with CBC, PKCS#7 with a default key length of 256 bits. All implementations also support AES128.
The ARTCipherParams object contains properties to configure encryption for a channel.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The ARTCipherParams object contains properties to configure encryption for a channel.
The `ARTCipherParams` object contains properties to configure encryption for a channel.

@tbedford @m-hulbert I’d suggest that this sort of formatting should be in the canonical documentation, what do you think?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with the formatting. It is already styled as code in the canonical docs though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will link to the page that user is already on. Is this what was expected? @lawrence-forooghian

*/
@interface ARTCipherParams : NSObject <ARTCipherParamsCompatible>

/// The algorithm to use for encryption. Only AES is supported.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tbedford @m-hulbert For consistency with the documentation for mode, should this not be the following?

Suggested change
/// The algorithm to use for encryption. Only AES is supported.
/// The algorithm to use for encryption. Only `"AES"` is supported.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should just be AES (no " ") as per the canonical table.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@property (readonly, nonatomic) NSUInteger keyLength;

/// The cipher mode. Only "CBC" is supported.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// The cipher mode. Only "CBC" is supported.
/// The cipher mode. Only `"CBC"` is supported.

@tbedford @m-hulbert as I mentioned elsewhere in this PR, I think this sort of formatting should be part of the canonical docs?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should just be CBC (no " ") as per the canonical table.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -44,11 +51,30 @@ NS_ASSUME_NONNULL_BEGIN

@end

/**
The ARTCrypto object ensures that message payloads are encrypted, can never be decrypted by Ably, and can only be decrypted by other clients that share the same secret symmetric key.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The ARTCrypto object ensures that message payloads are encrypted, can never be decrypted by Ably, and can only be decrypted by other clients that share the same secret symmetric key.
The `ARTCrypto` object ensures that message payloads are encrypted, can never be decrypted by Ably, and can only be decrypted by other clients that share the same secret symmetric key.

@tbedford @m-hulbert as I mentioned elsewhere in this PR, I think this sort of formatting should be part of the canonical docs?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with the change and this is also part of the canonical table already.

@@ -44,11 +51,30 @@ NS_ASSUME_NONNULL_BEGIN

@end

/**
The ARTCrypto object ensures that message payloads are encrypted, can never be decrypted by Ably, and can only be decrypted by other clients that share the same secret symmetric key.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The ARTCrypto object ensures that message payloads are encrypted, can never be decrypted by Ably, and can only be decrypted by other clients that share the same secret symmetric key.
The ARTCrypto class ensures that message payloads are encrypted, can never be decrypted by Ably, and can only be decrypted by other clients that share the same secret symmetric key.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure whether I agree with this description entirely. I think that the description of how encryption works in Ably is a good one, but it's not the ARTCrypto class itself that's responsible for performing the encryption. It’s more of a utility class, which helps you to create the parameters used to configure encryption elsewhere in the SDK.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is something like the following more accurate?

The `ARTCrypto` class enables you to set the parameters required for configuring the encryption of message payloads.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about

The ARTCrypto class enables you to generate the parameters required for configuring the encryption of message payloads.

@lawrence-forooghian @m-hulbert

/**
Retrieves, or optionally sets, the `ARTCipherParams` for the channel.
@param params Overrides the default parameters. A suitable key must be provided as a minimum.
@return `ARTCipherParams` A ARTCipherParams object, using the default values for any field not supplied.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@return `ARTCipherParams` A ARTCipherParams object, using the default values for any field not supplied.
@return `ARTCipherParams` A `ARTCipherParams` object, using the default values for any field not supplied.

/**
Retrieves, or optionally sets, the `ARTCipherParams` for the channel.
@param params Overrides the default parameters. A suitable key must be provided as a minimum.
@return `ARTCipherParams` A ARTCipherParams object, using the default values for any field not supplied.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be "An ARTCipherParams object", not "A".

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


/**
Generates a random key to be used in the encryption of the channel.
@param keyLength The length of the key, in bits, to be generated. If not specified, this is equal to the default keyLength of the default algorithm: for AES this is 256 bits.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@param keyLength The length of the key, in bits, to be generated. If not specified, this is equal to the default keyLength of the default algorithm: for AES this is 256 bits.
@param keyLength The length of the key, in bits, to be generated. If not specified, this is equal to the default key length of the default algorithm: for AES this is 256 bits.

@tbedford @m-hulbert I think an encryption algorithm is an abstract concept and not a class in our SDK, so I'm not sure that using keyLength, which suggests a property name, is appropriate here. Not sure though.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@QuintinWillison are you able to confirm this if possible?


/**
Generates a random key to be used in the encryption of the channel.
@param keyLength The length of the key, in bits, to be generated. If not specified, this is equal to the default keyLength of the default algorithm: for AES this is 256 bits.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maratal what does it mean to "not specify" a keyLength here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/**
Retrieves, or optionally sets, the `ARTCipherParams` for the channel.
@param params Overrides the default parameters. A suitable key must be provided as a minimum.
@return `ARTCipherParams` A ARTCipherParams object, using the default values for any field not supplied.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maratal this question applies to all of the @return tags where you've written the return type as part of the tag – do you think this is necessary? The return type is already displayed in the Jazzy documentation as part of the method signature:

Screenshot 2022-07-05 at 17 42 22

If you look at Apple's documentation (example), the "Return Value" section doesn't repeat the return type; rather, it's used to provide semantic information about the return value:

Screenshot 2022-07-05 at 17 44 50

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+ (NSData *)generateRandomKey:(NSUInteger)keyLength;

/**
Same as `+getDefaultParams:`, but with the default algorithm and key length: AES, 256 bits.
Copy link

@m-hulbert m-hulbert Jul 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description for generateRandomKey is the following in the canonical table:

Generates a random key to be used in the encryption of the channel.

I'm assuming this should be something like "Generates a random key to use for encrypting message payloads." instead given @lawrence-forooghian 's comment on getDefaultParams.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we have two methods with this name: one with parameter keyLength, and one without parameters. Canonical table contains only one description and notes that "If not specified, this is equal to the default keyLength of the default algorithm: for AES this is 256 bits.". So I decided to produce different description for method without parameter. Also I've messed up with the referred method: +getDefaultParams: instead of generateRandomKey:. Duh! @lawrence-forooghian @m-hulbert

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@QuintinWillison QuintinWillison removed their request for review July 11, 2022 12:19
@maratal
Copy link
Collaborator Author

maratal commented Sep 14, 2022

Closed in favor of #1491

@maratal maratal closed this Sep 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants