jwtAlgSetAsym (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

All

Firmware version:

1.70.00


jwtAlgSetAsym configures the JWT object to use an asymmetrical encryption.

Mainly for use with JWT objects created with jwtCreate.

To configure a symmetrical encryption, see jwtAlgSetSym.

 

 

Input:

jwt : SYSHANDLE

The JWT object to set the encryption algorithm for.

 

 

type : INT default 0

The kind of algorithm to use:

0

- No encryption

4

- RS256

5

- RS384

6

- RS512

7

- ES256

8

- ES384

9

- ES512

 

cert: STRING

The name of a certificate that contains the private key to use for encoding of the token.

 

pass: STRING

The password for the certificate.

 

 

Returns: INT

1

- Success

0

- Not supported.

-2

- Could not find JWT object.

-3

- Unsupported algorithm.

-4

- Could not find certificate or certificate was not provided for algorithm that required it.

-5

- Failed to parse certificate

-99

- Failed to set algorithm.

 

 

Declaration:

FUNCTION jwtAlgSetAsym : INT;
VAR_INPUT
  type  : INT;
  jwt   : SYSHANDLE;
  cert  : STRING;
  pass  : STRING;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
VAR
  rc  : INT;
  jwt : SYSHANDLE;
END_VAR;
 
BEGIN
  ...
  // Set algorithm
  rc := jwtAlgSetAsym(jwt:=jwt, type := 4, cert := "enc_key", pass := "test");
  ...
END;
 
END_PROGRAM;