Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
RS256.cs
1using System;
3using Waher.Script;
8
10{
15 {
23 : base(Array.Empty<ScriptNode>(), argumentTypes0, Start, Length, Expression)
24 {
25 }
26
35 : base(new ScriptNode[] { Rsa }, argumentTypes1Scalar, Start, Length, Expression)
36 {
37 }
38
42 public override string FunctionName => nameof(RS256);
43
47 public override string[] DefaultArgumentNames => new string[] { "Rsa" };
48
56 {
57 if (Arguments.Length == 0)
58 return new ObjectValue(new RsaSsaPkcsSha256());
59
60 object Obj = Arguments[0].AssociatedObjectValue;
61
62 if (Obj is RSA Rsa)
63 return new ObjectValue(new RsaSsaPkcsSha256(Rsa));
64 else if (Obj is RSAParameters Parameters)
65 return new ObjectValue(new RsaSsaPkcsSha256(Parameters));
66 else if (Obj is double NrBits)
67 return new ObjectValue(new RsaSsaPkcsSha256((int)NrBits));
68 else
69 throw new ScriptRuntimeException("Expected argument to be an RSA object, RSAParameters object, or a number of bits.", this);
70 }
71 }
72}
Class managing a script expression.
Definition: Expression.cs:41
Base class for multivariate funcions.
ScriptNode[] Arguments
Function arguments.
static readonly ArgumentType[] argumentTypes0
Zero parameters.
static readonly ArgumentType[] argumentTypes1Scalar
One scalar parameter.
Base class for all nodes in a parsed script tree.
Definition: ScriptNode.cs:69
int Length
Length of expression covered by node.
Definition: ScriptNode.cs:101
Expression Expression
Expression of which the node is a part.
Definition: ScriptNode.cs:177
int Start
Start position in script expression.
Definition: ScriptNode.cs:92
Collection of variables.
Definition: Variables.cs:25
Creates an RSASSA-PKCS1-v1_5 SHA-256 JSON Web Signature key.
Definition: RS256.cs:15
RS256(int Start, int Length, Expression Expression)
Creates an RSASSA-PKCS1-v1_5 SHA-256 JSON Web Signature key.
Definition: RS256.cs:22
override string[] DefaultArgumentNames
Default Argument names
Definition: RS256.cs:47
RS256(ScriptNode Rsa, int Start, int Length, Expression Expression)
Creates an RSASSA-PKCS1-v1_5 SHA-256 JSON Web Signature key.
Definition: RS256.cs:34
override IElement Evaluate(IElement[] Arguments, Variables Variables)
Evaluates the function.
Definition: RS256.cs:55
override string FunctionName
Name of the function
Definition: RS256.cs:42
RSASSA-PKCS1-v1_5 SHA-256 algorithm. https://tools.ietf.org/html/rfc3447#page-32
Basic interface for all types of elements.
Definition: IElement.cs:21