Aracılığıyla paylaş


MSCustomProtectedData customProtectedDataWithPolicy:protectedData:contentStartPosition:contentSize:completionBlock method

Asynchronously creates an MSCustomProtectedData object that can be used to read the specified block of protected data.

Signature

+ (void)customProtectedDataWithPolicy:(MSUserPolicy *)policy
                        protectedData:(NSData *)protectedData
                 contentStartPosition:(NSUInteger)contentStartPosition
                          contentSize:(NSUInteger)contentSize
                      completionBlock:(void(^)(MSCustomProtectedData *customProtectedData,NSError *error))completionBlock;

Parameters

Name Datatype Notes
policy
[MSUserPolicy](msuserpolicy-interface-objc.md) *
Required.
protectedData
NSData *
Required. The data to be read from.
contentStartPosition
NSUInteger
Required. Specifies theposition to begin reading in the protectedData.
contentSize
NSUInteger
Required. Specifies the size, in bytes, of the content to be read.
completionBlock
void(^)([MSCustomProtectedData](mscustomprotecteddata-interface-objc.md) *customProtectedData, NSError *error)
[!Note]
If the user cancels the operation, both the customProtectedData and error parameters will be NIL.

Defined in

MSCustomProtectedData.h

Supported Platforms

Minimum supported OS versions
iOS 7.0 and OS X 10.8

Remarks

You specify a range (contentStartPosition, contentSize) where the encrypted content is located in the protected NSData (protectedData).

  • If the existing content ends at the end of the backing NSData, you can specify NSUIntegerMax for contentSize.
  • The contentSize parameter is needed only for the cases when there is non-encrypted app-specific content after the encrypted content. This is because the framework needs to know where the encrypted content ends when performing decryption.
  • The contentSize parameter is specified in terms of the encrypted content; for example, it does include the size of the CBC padding. You can use the getEncryptedContentLength method to determine the size of the encrypted content from the size of the original, unencrypted content.
  • If the range defined by the parameters contentStartPosition and contentSize is not empty (for example, contentSize != 0), it must address an entire segment of encrypted content; that is, it must start from block 0 and must have a final block in the CBC case or should be 16-byte aligned in the ECB case.