forked from robballou/sublimetext-sshconfig
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPEM.sublime-syntax
148 lines (135 loc) · 3.8 KB
/
PEM.sublime-syntax
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
%YAML 1.2
---
# Not strictly just PEM. Includes some other stuff, just to be helpful.
# https://www.sublimetext.com/docs/syntax.html
# https://datatracker.ietf.org/doc/html/rfc7468 (PEM)
# https://datatracker.ietf.org/doc/html/rfc4716 (OpenSSH)
# https://datatracker.ietf.org/doc/html/rfc4880 (OpenPGP)
name: Private Encrypted Mail (PEM) Key
scope: source.pem
version: 2
extends: SSH Common.sublime-syntax
file_extensions:
- pem
hidden_file_extensions:
- cer
- cert
- crt
- id_dsa
- id_ed25519
- id_ed448
- id_eddsa
- id_rsa
first_line_match: |-
^(?x:
(-{4}[ -])
BEGIN [ ]
( (?:[0-9A-Z -]+[ ])? (?: PUBLIC | PRIVATE ) [ ] KEY
| (?:[0-9A-Z -]+[ ])? CERTIFICATE (?:[ ] REQUEST )?
| (?:[0-9A-Z -]+[ ])? PARAMETERS
| X509 [ ] CRL
| PKCS7
| PKCS [ ] \#7 [ ] SIGNED [ ] DATA
| CMS
| PGP [ ] MESSAGE (?:,[ ] PART [ ] \d+(?:/\d+)?)?
| PGP [ ] (?: PUBLIC | PRIVATE ) [ ] KEY [ ] BLOCK
| PGP [ ] SIGNATURE
)
([ -]-{4})
)
contexts:
main:
- include: comments-number-sign
- match: |-
^(?x:
(-{4}[ -])
BEGIN [ ]
( (?:[0-9A-Z -]+[ ])? (?: PUBLIC | PRIVATE ) [ ] KEY
| (?:[0-9A-Z -]+[ ])? CERTIFICATE (?:[ ] REQUEST )?
| (?:[0-9A-Z -]+[ ])? PARAMETERS
| X509 [ ] CRL
| PKCS7
| PKCS [ ] \#7 [ ] SIGNED [ ] DATA
| CMS
| PGP [ ] MESSAGE (?:,[ ] PART [ ] \d+(?:/\d+)?)?
| PGP [ ] (?: PUBLIC | PRIVATE ) [ ] KEY [ ] BLOCK
| PGP [ ] SIGNATURE
)
([ -]-{4})
)
scope: punctuation.section.block.begin.pem
push: pem-key
- include: setext-headings
pem-key:
- meta_scope: meta.block.pem
- match: ^\1END \2\3
scope: punctuation.section.block.end.pem
pop: 1
- include: comments-number-sign
- match: ^{{base64_char}}{1,100}(={0,3})?$
scope: string.unquoted.pem
captures:
1: punctuation.definition.string.end.pem
- include: headers
headers:
- match: ^(?i:(Comment))(:)
captures:
1: keyword.other.comment.pem
2: punctuation.separator.key-value.pem
push:
- meta_content_scope: comment.line.pem
- include: header-end
- match: ^((x-)?[\w-]+)(:)
captures:
1: meta.mapping.key.pem keyword.other.pem
2: variable.annotation.pem
3: punctuation.separator.key-value.pem
push: header-value
header-value:
- meta_scope: meta.mapping.pem
- meta_content_scope: meta.mapping.value.pem
- include: header-end
- include: punctuation-comma-sequence
- match: =
scope: punctuation.separator.key-value.pem
- match: '\b(?x: ENCRYPTED | MIC-ONLY | MIC-CLEAR )\b'
scope: storage.modifier.pem
- match: |-
\b(?x:
( AES-(?:128|256)-CBC
| DES-(?:EDE3-)?CBC
)\b
( (,) .+ )?
)
captures:
1: meta.function-call.identifier.pem
support.function.cipher.ssh.crypto
2: meta.function-call.arguments.pem
3: punctuation.section.arguments.begin.pem
header-end:
- match: \\\r?\n
scope: punctuation.separator.continuation.line.pem
push:
- match: ^
pop: 1
- match: (?=$)
pop: 1
setext-headings:
- match: ^(?:=+|(?=\S))
branch_point: maybe-heading
branch:
- setext-heading
- not-heading
setext-heading:
- meta_scope: markup.heading.pem
- meta_content_scope: entity.name.section.pem
- match: ^(={5,})[ \t]*$(\n?)
captures:
1: punctuation.definition.heading.setext.pem
2: meta.whitespace.newline.pem
pop: 1
- match: ^(?!=+)$
fail: maybe-heading
not-heading:
- match: ''
pop: 1