Skip to content

Commit

Permalink
add addSubkeyBindingCertification method to PGPPublicKey
Browse files Browse the repository at this point in the history
  • Loading branch information
Valodim committed Jul 2, 2014
1 parent 09d85b7 commit 968405e
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions pg/src/main/java/org/spongycastle/openpgp/PGPPublicKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,31 @@ private static PGPPublicKey removeCert(
return returnKey;
}

/**
* Add a subkey binding certification, changing the key type from master to subkey.
*
* @param key the key the revocation is to be added to.
* @param certification the key signature to be added.
* @return the new changed public key object.
*/
public static PGPPublicKey addSubkeyBindingCertification(
PGPPublicKey key,
PGPSignature certification)
{
// make sure no subSigs are previously present
if (!key.isMasterKey())
{
throw new IllegalArgumentException("key is already a subkey!");
}

PGPPublicKey returnKey = new PGPPublicKey(key);

returnKey.subSigs = new ArrayList();
returnKey.subSigs.add(certification);
return returnKey;
}


/**
* Add a revocation or some other key certification to a key.
*
Expand Down

0 comments on commit 968405e

Please sign in to comment.