本文介绍了在ObjectivePGP中使用BCPG公钥生成PGPKey,其返回值为nil的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的公共密钥:

----- BEGIN PGP签名-----
版本:BCPG v1.48

-----BEGIN PGP SIGNATURE-----
Version: BCPG v1.48

LQH + BFomf0kDBADUrV1KFuGFxvRhA7yCO07q5vtvKTjnP4wRn5KyXMyjYX2R5rvGkQkpWwBfzGCxMA + ieeW5mWFrNFod4A6wXGzXiiEZ3/i4EfvyipKk38sLVdW8I3sux1lnjp4t + 6p1RTAVAwx0yWGjNHlLcbwhtFNyoIW1fxUckVZwW3PJrJm2owARAQAB/gMDAkpUpa7K3etCYNSXyy/c0CfQ1fMVnWtls9UNiLyj8Hi3qyaBK0E942xZQkiq60qCirnPtWTsndKkMnHuGcOVSusYwP20aKj2Z4vrfKAtSx1CoJVPtk0M/QT/cbUQqpkFrow6RBxCI5k/6xaxK + 174WtEQRSD/Dzr99jPBdbI8zYB/1Nzj7uFZPci0i8x04TzR8aSFx5vTXc9v5nSEYUoNd + B0S2CO51xWf4qeb0YSVT4cvu5IhyPcpKuC/L6raNPRfFPg + c1r2geiNeXV92L7KQEIVzcTsypkWufZdp + cUIHCRD ++ aXl3YdOQkkzc3rwtxXvHxiriguJPvzzqmmjXYjgdEioKXTXHF/MGEN/Qt2pl3accdGVLkhhGdcPQ68sIjpaOPFv8cqb0XLFNIznd5abmFh50vJQmA0SH2kmuBW4b3XyAHPRflL4vfadxNeE9Nr81SVnfxdYo23pigJWed6ENyHKo392dDnNNi0ctAdyZXl0dW0xiK4EEwMCABUFAlomf0kCGwMECwkIBwYVCAIJCgsADQkQ + s3X2JD + TnkCGwx5XQQAgWZoL3LsBmllRg8wKQdVqxYo1wPgcVKJm + fT5yBpY3fRxRYgiAZs + Kq3/XRIOflKoqzskCbvEfKyZHp2bUcy1/NwmMrCLx1wHrXp7F64ChJGyTsx11gdRYfM5j3QwPqfh6AxvIcIyHyx5SXJMDIJx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7NGjPLU+nPTGlYdOGFay5wDPx2Q4kGDfjsMYdSArLuLKNVTBPW1i0ffE3MFICNx0egPWCTyEOZFOJtY0GKQqrdOD+0d0YpLesCf9oNcYWdJZBu65DCpPsryii7NvzGNVk1PD4eNnXtjG6heHLw5NOZsOL/7XUhiorE3gCPZlsm2D0Cq811nH2CX8ljdXnnOcitOVzzNHg8zG75xqW/pnfEI8BtvtprhoB7OTJw6ZBoWFGAzZI4LJujhMk2DI85AC5NNUsDhB6w0vTV3/xGTHnufsWIOX/E1TVvkpt01XyZxnOePu3Muqlf/3qIY4AK3P0PlFdE4zeZ9tcZ9mhn3+1/WltDjQN+HT3hO7/af/DT20Ej/Gkg+OBNpY2w/5OgRihUiIrgQYAwIAFQUCWiZ/SQIbAwQLCQgHBhUIAgkKCwANCRD6zdfYkP5OeQIbDJggA/9b8OAsMG+N7MLRXA7OCRjFPO3+yhlWfqmI9gKwaC0ziSGo/JWcLByRS/07BCjidjvSGIzWXonwfM+vg/7WCkHmCdTB2k//GJ42mSqnTY6ymgzid/YRT1DcXMyyWw5LyR8EZVTSROxuurZmHJwYZPSTBXYX9Rk/19T2dh5L9VGB+g==
-----END PGP SIGNATURE----

从ObjectivePGP libaray生成pgpkey libaray

Generating pgpkey from ObjectivePGP libaraylibaray

尝试过两种类型,但无法获得pgpKey

Tried with both the types but not able to get pgpKey

1)我在下面的代码中使用了上面的publickKeyData,但是它在键的NSArray中返回nil

1)I have used the above publickKeyData in below code but it returns nil in NSArray of keys

   NSData* publickKeyData = [publickKey 
   dataUsingEncoding:NSUTF8StringEncoding];

   NSArray<PGPKey *> *keys = [ObjectivePGP readKeysFromData:publickKeyData];

2)我在下面的代码中使用了上面的publickKeyData,但它在PGPPacket中返回nil

2)I have used the above publickKeyData in below code but it returns nil in PGPPacket

  NSUInteger offset = 0; 
  NSUInteger nextPacketOffset = 0;

  PGPPacket * pgpPacket =   [PGPPacketFactory packetWithData:publickKeyData offset:offset nextPacketOffset:&nextPacketOffset];

 NSArray<PGPPacket*> * array = @[pgpPacket];

 PGPPartialKey *pgpPartialKey = [[PGPPartialKey alloc] initWithPackets:array ];

  PGPKey *pgpKey =   [[PGPKey alloc] initWithSecretKey:nil publicKey:pgpPartialKey];

 NSArray<PGPKey *> * pgpKeys =  @[pgpKey];

我尝试了两种类型,但无法从ObjectivePGP 我做错了上述键在带有bouncycastle pgp的android中有效,但在ObjectivePGP中不起作用

i have tried with both types but not able to get the PGPKey from ObjectivePGP libaray, i'm doing wrong this above key works in android with bouncycastle pgp but not in ObjectivePGP

如何解决这个问题?

任何帮助将不胜感激!

推荐答案

在项目存储库中跟踪此问题: https://github.com/krzyzanowskim/ObjectivePGP/issues/93

This question is tracked in the project repository: https://github.com/krzyzanowskim/ObjectivePGP/issues/93

这篇关于在ObjectivePGP中使用BCPG公钥生成PGPKey,其返回值为nil的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 15:33