Index: crypto/openpgp_symmetric_encryption.h |
diff --git a/crypto/openpgp_symmetric_encryption.h b/crypto/openpgp_symmetric_encryption.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d49d216265e1691a5367ad84b0ff75fc237ee804 |
--- /dev/null |
+++ b/crypto/openpgp_symmetric_encryption.h |
@@ -0,0 +1,45 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CRYPTO_OPENPGP_SYMMETRIC_ENCRYPTION_H_ |
+#define CRYPTO_OPENPGP_SYMMETRIC_ENCRYPTION_H_ |
+#pragma once |
+ |
+#include <string> |
+ |
+#include "base/string_piece.h" |
+ |
+namespace crypto { |
+ |
+// OpenPGPSymmetricEncrytion implements enough of RFC 4880 to read and write |
+// uncompressed, symmetrically encrypted data. You can create ciphertext |
+// compatable with this code from the command line with: |
+// gpg --compress-algo=NONE --cipher-algo=AES -c |
+// |
+// Likewise, the output of this can be decrypted on the command line with: |
+// gpg < input |
+class OpenPGPSymmetricEncrytion { |
+ public: |
+ enum Result { |
+ OK, |
+ UNKNOWN_CIPHER, // you forgot to pass --cipher-algo=AES to gpg |
+ UNKNOWN_HASH, |
+ NOT_SYMMETRICALLY_ENCRYPTED, // it's OpenPGP data, but not correct form |
+ COMPRESSED, // you forgot to pass --compress-algo=NONE |
+ PARSE_ERROR, // it's not OpenPGP data. |
+ INTERNAL_ERROR, |
+ }; |
+ |
+ static Result Decrypt(base::StringPiece encrypted, |
+ base::StringPiece passphrase, |
+ std::string *out); |
+ |
+ static std::string Encrypt(base::StringPiece plaintext, |
+ base::StringPiece passphrase); |
+}; |
+ |
+} // namespace crypto |
+ |
+#endif // CRYPTO_OPENPGP_SYMMETRIC_ENCRYPTION_H_ |
+ |