30
30
register-codec [
31
31
name: 'ssh-key
32
32
title: "Secure Shell Key"
33
- ; not using suffixes as there is no standard!
33
+ suffixes: [ %.key ]
34
34
35
35
decode : function [
36
36
"Decodes and initilize SSH key"
88
88
all [
89
89
parse data [
90
90
'SEQUENCE into [
91
- 'SEQUENCE set v block! ; AlgorithmIdentifier
92
- 'BIT_STRING set data binary! ; PublicKey
91
+ 'SEQUENCE set v: block! ; AlgorithmIdentifier
92
+ 'BIT_STRING set data: binary! ; PublicKey
93
93
(
94
94
data: codecs/der/decode data
95
95
)
98
98
v/OBJECT_IDENTIFIER = #{ 2A864886F70D010101 } ;= rsaEncryption
99
99
parse data [
100
100
'SEQUENCE into [
101
- 'INTEGER set n binary! ;modulus
102
- 'INTEGER set e binary! ;publicExponent
101
+ 'INTEGER set n: binary! ;modulus
102
+ 'INTEGER set e: binary! ;publicExponent
103
103
]
104
104
]
105
105
]
@@ -110,8 +110,8 @@ wrap [
110
110
; resolve RSA public data from the DER structure (PKCS#1)
111
111
parse data [
112
112
'SEQUENCE into [
113
- 'INTEGER set n binary! ;modulus
114
- 'INTEGER set e binary! ;publicExponent
113
+ 'INTEGER set n: binary! ;modulus
114
+ 'INTEGER set e: binary! ;publicExponent
115
115
]
116
116
]
117
117
; resolve RSA handle from parsed data
@@ -121,15 +121,15 @@ wrap [
121
121
; resolve RSA private data from the DER structure (PKCS#1)
122
122
parse data [
123
123
'SEQUENCE into [
124
- 'INTEGER set v binary! ;version
125
- 'INTEGER set n binary! ;modulus
126
- 'INTEGER set e binary! ;publicExponent
127
- 'INTEGER set d binary! ;privateExponent
128
- 'INTEGER set p binary! ;prime1
129
- 'INTEGER set q binary! ;prime2
130
- 'INTEGER set dp binary! ;exponent1 d mod (p-1)
131
- 'INTEGER set dq binary! ;exponent2 d mod (q-1)
132
- 'INTEGER set inv binary! ;coefficient (inverse of q) mod p
124
+ 'INTEGER set v: binary! ;version
125
+ 'INTEGER set n: binary! ;modulus
126
+ 'INTEGER set e: binary! ;publicExponent
127
+ 'INTEGER set d: binary! ;privateExponent
128
+ 'INTEGER set p: binary! ;prime1
129
+ 'INTEGER set q: binary! ;prime2
130
+ 'INTEGER set dp: binary! ;exponent1 d mod (p-1)
131
+ 'INTEGER set dq: binary! ;exponent2 d mod (q-1)
132
+ 'INTEGER set inv: binary! ;coefficient (inverse of q) mod p
133
133
to end
134
134
]
135
135
to end
0 commit comments