Objective-C
Objective-C
Set the JWE Protected Header
See more JSON Web Encryption (JWE) Examples
Demonstrates Jwe.SetProtectedHeader, which sets the integrity-protected JWE header from a JsonObject. The header specifies the key-management algorithm (alg) and content-encryption algorithm (enc).
Background. The protected header is integrity-protected and applies to all recipients. It is configured before encrypting.
Chilkat Objective-C Downloads
#import <CkoJwe.h>
#import <CkoJsonObject.h>
BOOL success = NO;
CkoJwe *jwe = [[CkoJwe alloc] init];
// Build the JWE protected header. The "alg" member names the key-management algorithm and the "enc"
// member names the content-encryption algorithm.
CkoJsonObject *header = [[CkoJsonObject alloc] init];
[header UpdateString: @"alg" value: @"A256KW"];
[header UpdateString: @"enc" value: @"A256GCM"];
// Set the protected header on the JWE. The protected header is integrity-protected and applies to
// all recipients.
success = [jwe SetProtectedHeader: header];
if (success == NO) {
NSLog(@"%@",jwe.LastErrorText);
return;
}
NSLog(@"%@",@"Protected header set.");