aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/x509_obj.h4
-rw-r--r--src/x509_obj.cpp16
2 files changed, 20 insertions, 0 deletions
diff --git a/include/x509_obj.h b/include/x509_obj.h
index f7f110a42..47c95a041 100644
--- a/include/x509_obj.h
+++ b/include/x509_obj.h
@@ -22,6 +22,10 @@ class X509_Object
SecureVector<byte> signature() const;
AlgorithmIdentifier signature_algorithm() const;
+ static MemoryVector<byte> make_signed(class PK_Signer*,
+ const AlgorithmIdentifier&,
+ const MemoryRegion<byte>&);
+
bool check_signature(class X509_PublicKey&) const;
void encode(Pipe&, X509_Encoding = PEM) const;
diff --git a/src/x509_obj.cpp b/src/x509_obj.cpp
index 5750f9bd1..44cbe35d8 100644
--- a/src/x509_obj.cpp
+++ b/src/x509_obj.cpp
@@ -192,6 +192,22 @@ bool X509_Object::check_signature(X509_PublicKey& pub_key) const
}
/*************************************************
+* Apply the X.509 SIGNED macro *
+*************************************************/
+MemoryVector<byte> X509_Object::make_signed(PK_Signer* signer,
+ const AlgorithmIdentifier& algo,
+ const MemoryRegion<byte>& tbs_bits)
+ {
+ return DER_Encoder()
+ .start_cons(SEQUENCE)
+ .raw_bytes(tbs_bits)
+ .encode(algo)
+ .encode(signer->sign_message(tbs_bits), BIT_STRING)
+ .end_cons()
+ .get_contents();
+ }
+
+/*************************************************
* Try to decode the actual information *
*************************************************/
void X509_Object::do_decode()