aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-10-30 13:21:03 -0400
committerJack Lloyd <[email protected]>2016-10-30 13:21:03 -0400
commitb4c9de4d321144f4c1c8d43e5a827011c8c4fca5 (patch)
tree42994bce83acbf5cb80224a3e282963e7181a335
parent3ebda233c27f74f57aa1a183038f4782f197d5c5 (diff)
Remove openpgp module
Just handled base64 encoding/decoding with a CRC and that's it. This would be better off being rewritten as part of a larger effort to support a meaningful subset of OpenPGP, and does not seem useful on its own.
-rw-r--r--src/lib/misc/openpgp/info.txt9
-rw-r--r--src/lib/misc/openpgp/openpgp.cpp196
-rw-r--r--src/lib/misc/openpgp/openpgp.h61
3 files changed, 0 insertions, 266 deletions
diff --git a/src/lib/misc/openpgp/info.txt b/src/lib/misc/openpgp/info.txt
deleted file mode 100644
index b95c88ef7..000000000
--- a/src/lib/misc/openpgp/info.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-define OPENPGP_CODEC 20131128
-
-load_on auto
-
-<requires>
-codec_filt
-crc24
-filters
-</requires>
diff --git a/src/lib/misc/openpgp/openpgp.cpp b/src/lib/misc/openpgp/openpgp.cpp
deleted file mode 100644
index 7a08a93ef..000000000
--- a/src/lib/misc/openpgp/openpgp.cpp
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
-* OpenPGP Codec
-* (C) 1999-2007 Jack Lloyd
-*
-* Botan is released under the Simplified BSD License (see license.txt)
-*/
-
-#include <botan/openpgp.h>
-#include <botan/filters.h>
-#include <botan/basefilt.h>
-#include <botan/charset.h>
-#include <botan/crc24.h>
-
-namespace Botan {
-
-/*
-* OpenPGP Base64 encoding
-*/
-std::string PGP_encode(
- const byte input[], size_t length,
- const std::string& label,
- const std::map<std::string, std::string>& headers)
- {
- const std::string PGP_HEADER = "-----BEGIN PGP " + label + "-----\n";
- const std::string PGP_TRAILER = "-----END PGP " + label + "-----\n";
- const size_t PGP_WIDTH = 64;
-
- std::string pgp_encoded = PGP_HEADER;
-
- if(headers.find("Version") != headers.end())
- pgp_encoded += "Version: " + headers.find("Version")->second + "\n";
-
- std::map<std::string, std::string>::const_iterator i = headers.begin();
- while(i != headers.end())
- {
- if(i->first != "Version")
- pgp_encoded += i->first + ": " + i->second + "\n";
- ++i;
- }
- pgp_encoded += "\n";
-
- Pipe pipe(new Fork(
- new Base64_Encoder(true, PGP_WIDTH),
- new Chain(new Hash_Filter(new CRC24), new Base64_Encoder)
- )
- );
-
- pipe.process_msg(input, length);
-
- pgp_encoded += pipe.read_all_as_string(0);
- pgp_encoded += "=" + pipe.read_all_as_string(1) + "\n";
- pgp_encoded += PGP_TRAILER;
-
- return pgp_encoded;
- }
-
-/*
-* OpenPGP Base64 encoding
-*/
-std::string PGP_encode(const byte input[], size_t length,
- const std::string& type)
- {
- std::map<std::string, std::string> empty;
- return PGP_encode(input, length, type, empty);
- }
-
-/*
-* OpenPGP Base64 decoding
-*/
-secure_vector<byte> PGP_decode(DataSource& source,
- std::string& label,
- std::map<std::string, std::string>& headers)
- {
- const size_t RANDOM_CHAR_LIMIT = 5;
-
- const std::string PGP_HEADER1 = "-----BEGIN PGP ";
- const std::string PGP_HEADER2 = "-----";
- size_t position = 0;
-
- while(position != PGP_HEADER1.length())
- {
- byte b;
- if(!source.read_byte(b))
- throw Decoding_Error("PGP: No PGP header found");
- if(b == PGP_HEADER1[position])
- ++position;
- else if(position >= RANDOM_CHAR_LIMIT)
- throw Decoding_Error("PGP: Malformed PGP header");
- else
- position = 0;
- }
- position = 0;
- while(position != PGP_HEADER2.length())
- {
- byte b;
- if(!source.read_byte(b))
- throw Decoding_Error("PGP: No PGP header found");
- if(b == PGP_HEADER2[position])
- ++position;
- else if(position)
- throw Decoding_Error("PGP: Malformed PGP header");
-
- if(position == 0)
- label += static_cast<char>(b);
- }
-
- headers.clear();
- bool end_of_headers = false;
- while(!end_of_headers)
- {
- std::string this_header;
- byte b = 0;
- while(b != '\n')
- {
- if(!source.read_byte(b))
- throw Decoding_Error("PGP: Bad armor header");
- if(b != '\n')
- this_header += static_cast<char>(b);
- }
-
- end_of_headers = true;
- for(size_t j = 0; j != this_header.length(); ++j)
- if(!Charset::is_space(this_header[j]))
- end_of_headers = false;
-
- if(!end_of_headers)
- {
- std::string::size_type pos = this_header.find(": ");
- if(pos == std::string::npos)
- throw Decoding_Error("OpenPGP: Bad headers");
-
- std::string key = this_header.substr(0, pos);
- std::string value = this_header.substr(pos + 2, std::string::npos);
- headers[key] = value;
- }
- }
-
- Pipe base64(new Base64_Decoder,
- new Fork(nullptr,
- new Chain(new Hash_Filter(new CRC24),
- new Base64_Encoder)
- )
- );
- base64.start_msg();
-
- const std::string PGP_TRAILER = "-----END PGP " + label + "-----";
- position = 0;
- bool newline_seen = 0;
- std::string crc;
- while(position != PGP_TRAILER.length())
- {
- byte b;
- if(!source.read_byte(b))
- throw Decoding_Error("PGP: No PGP trailer found");
- if(b == PGP_TRAILER[position])
- ++position;
- else if(position)
- throw Decoding_Error("PGP: Malformed PGP trailer");
-
- if(b == '=' && newline_seen)
- {
- while(b != '\n')
- {
- if(!source.read_byte(b))
- throw Decoding_Error("PGP: Bad CRC tail");
- if(b != '\n')
- crc += static_cast<char>(b);
- }
- }
- else if(b == '\n')
- newline_seen = true;
- else if(position == 0)
- {
- base64.write(b);
- newline_seen = false;
- }
- }
- base64.end_msg();
-
- if(!crc.empty() && crc != base64.read_all_as_string(1))
- throw Decoding_Error("PGP: Corrupt CRC");
-
- return base64.read_all();
- }
-
-/*
-* OpenPGP Base64 decoding
-*/
-secure_vector<byte> PGP_decode(DataSource& source, std::string& label)
- {
- std::map<std::string, std::string> ignored;
- return PGP_decode(source, label, ignored);
- }
-
-}
-
diff --git a/src/lib/misc/openpgp/openpgp.h b/src/lib/misc/openpgp/openpgp.h
deleted file mode 100644
index 538b31342..000000000
--- a/src/lib/misc/openpgp/openpgp.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
-* OpenPGP Codec
-* (C) 1999-2007 Jack Lloyd
-*
-* Botan is released under the Simplified BSD License (see license.txt)
-*/
-
-#ifndef BOTAN_OPENPGP_CODEC_H__
-#define BOTAN_OPENPGP_CODEC_H__
-
-#include <botan/data_src.h>
-#include <string>
-#include <map>
-
-namespace Botan {
-
-/**
-* @param input the input data
-* @param length length of input in bytes
-* @param label the human-readable label
-* @param headers a set of key/value pairs included in the header
-*/
-BOTAN_DLL std::string PGP_encode(
- const byte input[],
- size_t length,
- const std::string& label,
- const std::map<std::string, std::string>& headers);
-
-/**
-* @param input the input data
-* @param length length of input in bytes
-* @param label the human-readable label
-*/
-BOTAN_DLL std::string PGP_encode(
- const byte input[],
- size_t length,
- const std::string& label);
-
-/**
-* @param source the input source
-* @param label is set to the human-readable label
-* @param headers is set to any headers
-* @return decoded output as raw binary
-*/
-BOTAN_DLL secure_vector<byte> PGP_decode(
- DataSource& source,
- std::string& label,
- std::map<std::string, std::string>& headers);
-
-/**
-* @param source the input source
-* @param label is set to the human-readable label
-* @return decoded output as raw binary
-*/
-BOTAN_DLL secure_vector<byte> PGP_decode(
- DataSource& source,
- std::string& label);
-
-}
-
-#endif