Skip to content

Commit 8b56f6d

Browse files
committed
Add enum class representing RSA parameters (to be used with JWKS).
1 parent 8ad7955 commit 8b56f6d

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

src/Enum/Rsa/Parameter.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
namespace Pdsinterop\Solid\Auth\Enum\Rsa;
4+
5+
/**
6+
* Parameters for RSA Public Keys
7+
*
8+
* These members MUST be present for RSA public keys.
9+
*
10+
* The RSA Key blinding operation [Kocher], which is a defense against some
11+
* timing attacks, requires all of the RSA key values "n", "e", and "d".
12+
*
13+
* However, some RSA private key representations do not include the public
14+
* exponent "e", but only include the modulus "n" and the private exponent
15+
* "d". This is true, for instance, of the Java RSAPrivateKeySpec API, which
16+
* does not include the public exponent "e" as a parameter. So as to enable
17+
* RSA key blinding, such representations should be avoided. For Java, the
18+
* RSAPrivateCrtKeySpec API can be used instead. Section 8.2.2(i) of the
19+
* "Handbook of Applied Cryptography" [HAC] discusses how to compute the
20+
* remaining RSA private key parameters, if needed, using only "n", "e",
21+
* and "d".}
22+
*
23+
* @see https://tools.ietf.org/html/rfc7518#section-6.3
24+
*/
25+
class Parameter
26+
{
27+
/**
28+
* The "e" (exponent) parameter contains the exponent value for the RSA
29+
* public key. It is represented as a Base64urlUInt-encoded value. For
30+
* instance, when representing the value 65537, the octet sequence to be
31+
* base64url-encoded MUST consist of the three octets [1, 0, 1]; the
32+
* resulting representation for this value is "AQAB".
33+
*/
34+
public const PUBLIC_EXPONENT = 'e';
35+
36+
/**
37+
* The "n" (modulus) parameter contains the modulus value for the RSA public
38+
* key. It is represented as a Base64urlUInt-encoded value.
39+
*/
40+
public const PUBLIC_MODULUS = 'n';
41+
42+
/**
43+
* The "d" (private exponent) parameter contains the private exponent value
44+
* for the RSA private key. It is represented as a Base64urlUInt-encoded
45+
* value.}
46+
*/
47+
public const PRIVATE_EXPONENT = 'd';
48+
}

0 commit comments

Comments
 (0)