openpgpjs/openpgpjs — pull request #223 by toberndo (2014-05-14 10:07:28+00:00)
Title: Allow private keys for verify methods in Cleartext and Message class.

Currently verify methods in `Cleartext` and `Message` class require `Key` objects as parameters which are public keys. It's an unnecessary limitation to not allow privat keys here. Also e.g. the encrypt method in the `Message` class supports both type of keys.

With this PR the limitation is removed and verify methods support also private keys. Actually the verify method of the signature packet always supported also private key packets.

With this comes a cleanup of the `Key` interface:

#### `getKeyPacket` method removed (or redefined, see next point)

The current `getKeyPacket()` just returns the `primaryKey` attribute. We don't have anywhere else these kind of simple getters. `key.getKeyPacket()` is therefore replaced with direct access to `key.primaryKey`.

#### `getPublicKeyPacket` and `getPrivateKeyPacket` replaced with `getKeyPacket`

There can never be public AND private key packets in a key. When we query for key packets of a key by keyid there don't need to be two methods for that. `getKeyPacket` returns either public or private key packets.

Instead of:

```
var keyPacket;
if (key.isPublic()) {
keyPacket = key.getPublicKeyPacket([keyid]);
} else {
keyPacket = key.getPrivateKeyPacket([keyid]);
}
```

we can have:

```
var keyPacket = key.getKeyPacket([keyid]);
```