File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -126,6 +126,26 @@ try:
126
126
]
127
127
}
128
128
129
+ # Example of using Python crypto to sign data using openssl with Ps256
130
+ from cryptography.hazmat.primitives import hashes, serialization
131
+ from cryptography.hazmat.primitives.asymmetric import padding
132
+
133
+ def sign_ps256 (data : bytes , key_path : str ) -> bytes :
134
+ with open (key_path, " rb" ) as key_file:
135
+ private_key = serialization.load_pem_private_key(
136
+ key_file.read(),
137
+ password = None ,
138
+ )
139
+ signature = private_key.sign(
140
+ data,
141
+ padding.PSS(
142
+ mgf = padding.MGF1(hashes.SHA256()),
143
+ salt_length = padding.PSS .MAX_LENGTH
144
+ ),
145
+ hashes.SHA256()
146
+ )
147
+ return signature
148
+
129
149
# Create a builder add a thumbnail resource and an ingredient file.
130
150
builder = Builder(manifest_json)
131
151
You can’t perform that action at this time.
0 commit comments