aboutsummaryrefslogtreecommitdiffstats
path: root/doc/examples
diff options
context:
space:
mode:
authorlloyd <[email protected]>2006-05-19 00:09:21 +0000
committerlloyd <[email protected]>2006-05-19 00:09:21 +0000
commitf61b8ece49d403a73855c88b51e2e45d1faa70b4 (patch)
tree733fbb1461753da5654cdcf66b5672aa21881e16 /doc/examples
parentf090e030be53e574fecbe7cf50edfb5fdacb53e1 (diff)
Update some of the examples to reflect the new APIs.
Diffstat (limited to 'doc/examples')
-rw-r--r--doc/examples/asn1.cpp16
-rw-r--r--doc/examples/x509info.cpp22
2 files changed, 24 insertions, 14 deletions
diff --git a/doc/examples/asn1.cpp b/doc/examples/asn1.cpp
index 91fb995e1..d3b4a65b9 100644
--- a/doc/examples/asn1.cpp
+++ b/doc/examples/asn1.cpp
@@ -33,6 +33,8 @@
/*******************************************************************/
#include <botan/botan.h>
+#include <botan/bigint.h>
+#include <botan/der_enc.h>
#include <botan/ber_dec.h>
#include <botan/asn1_obj.h>
#include <botan/oids.h>
@@ -143,13 +145,13 @@ void decode(BER_Decoder& decoder, u32bit level)
else if(type_tag == OBJECT_ID)
{
OID oid;
- BER::decode(data, oid);
+ data.decode(oid);
emit(type_name(type_tag), level, length, OIDS::lookup(oid));
}
else if(type_tag == INTEGER)
{
BigInt number;
- BER::decode(data, number);
+ data.decode(number);
SecureVector<byte> rep;
@@ -168,7 +170,7 @@ void decode(BER_Decoder& decoder, u32bit level)
else if(type_tag == BOOLEAN)
{
bool boolean;
- BER::decode(data, boolean);
+ data.decode(boolean);
emit(type_name(type_tag),
level, length, (boolean ? "true" : "false"));
}
@@ -179,7 +181,7 @@ void decode(BER_Decoder& decoder, u32bit level)
else if(type_tag == OCTET_STRING)
{
SecureVector<byte> bits;
- BER::decode(data, bits, type_tag);
+ data.decode(bits, type_tag);
bool not_text = false;
for(u32bit j = 0; j != bits.size(); j++)
@@ -193,7 +195,7 @@ void decode(BER_Decoder& decoder, u32bit level)
else if(type_tag == BIT_STRING)
{
SecureVector<byte> bits;
- BER::decode(data, bits, type_tag);
+ data.decode(bits, type_tag);
std::vector<bool> bit_set;
@@ -222,7 +224,7 @@ void decode(BER_Decoder& decoder, u32bit level)
type_tag == BMP_STRING)
{
ASN1_String str;
- BER::decode(data, str);
+ data.decode(str);
if(UTF8_TERMINAL)
emit(type_name(type_tag), level, length, iso2utf(str.iso_8859()));
else
@@ -231,7 +233,7 @@ void decode(BER_Decoder& decoder, u32bit level)
else if(type_tag == UTC_TIME || type_tag == GENERALIZED_TIME)
{
X509_Time time;
- BER::decode(data, time);
+ data.decode(time);
emit(type_name(type_tag), level, length, time.readable_string());
}
else
diff --git a/doc/examples/x509info.cpp b/doc/examples/x509info.cpp
index cbb9c0a11..87ffcc30f 100644
--- a/doc/examples/x509info.cpp
+++ b/doc/examples/x509info.cpp
@@ -13,6 +13,8 @@
using namespace Botan;
#include <iostream>
+#include <iterator>
+#include <algorithm>
std::string to_hex(const SecureVector<byte>& bin)
{
@@ -24,14 +26,20 @@ std::string to_hex(const SecureVector<byte>& bin)
return "(none)";
}
-void do_print(const std::string& what, const std::string& val)
+void do_print(const std::string& what, const std::string& vals)
+ // const std::vector<std::string>& vals)
{
- if(val == "")
+ if(vals.size() == 0)
return;
- std::cout << " " << what << ": " << val << std::endl;
+ std::cout << " " << what << ": ";
+ std::cout << vals;
+ //std::copy(vals.begin(), vals.end(),
+ // std::ostream_iterator<std::string>(std::cout, " "));
+ std::cout << "\n";
}
+
void do_subject(const X509_Certificate& cert, const std::string& what)
{
do_print(what, cert.subject_info(what));
@@ -103,20 +111,20 @@ int main(int argc, char* argv[])
std::cout << " CRL Sign\n";
}
- std::vector<OID> policies = cert.policies();
+ std::vector<std::string> policies = cert.policies();
if(policies.size())
{
std::cout << "Policies: " << std::endl;
for(u32bit j = 0; j != policies.size(); j++)
- std::cout << " " << OIDS::lookup(policies[j]) << std::endl;
+ std::cout << " " << policies[j] << std::endl;
}
- std::vector<OID> ex_constraints = cert.ex_constraints();
+ std::vector<std::string> ex_constraints = cert.ex_constraints();
if(ex_constraints.size())
{
std::cout << "Extended Constraints: " << std::endl;
for(u32bit j = 0; j != ex_constraints.size(); j++)
- std::cout << " " << OIDS::lookup(ex_constraints[j]) << std::endl;
+ std::cout << " " << ex_constraints[j] << std::endl;
}
std::cout << "Signature algorithm: " <<