diff --git a/src/crypto/public_key/elliptic/ecdh.js b/src/crypto/public_key/elliptic/ecdh.js new file mode 100644 index 00000000..fc28064d --- /dev/null +++ b/src/crypto/public_key/elliptic/ecdh.js @@ -0,0 +1,129 @@ +// OpenPGP.js - An OpenPGP implementation in javascript +// Copyright (C) 2015-2016 Decentral +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 3.0 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +// Key encryption and decryption for RFC 6637 ECDH + +/** + * @requires crypto/hash + * @requires crypto/cipher + * @requires crypto/rfc3394 + * @requires crypto/public_key/elliptic/curves + * @requires crypto/public_key/jsbn + * @requires type/oid + * @requires type/kdf_params + * @requires enums + * @requires util + * @module crypto/public_key/elliptic/ecdh + */ + +'use strict'; + +import BigInteger from '../jsbn.js'; +import curves from './curves.js'; +import cipher from '../../cipher'; +import hash from '../../hash'; +import rfc3394 from '../../rfc3394.js'; +import enums from '../../../enums.js'; +import util from '../../../util.js'; +import type_kdf_params from '../../../type/kdf_params.js'; +import type_oid from '../../../type/oid.js'; + +function hex2Uint8Array(hex) { + var result = new Uint8Array(hex.length/2); + for (var k=0; k