| 575 | } |
| 576 | |
| 577 | bool CECSigningPrivateKey::ParsePEM( const char *pBuffer, size_t cBytes ) |
| 578 | { |
| 579 | Wipe(); |
| 580 | |
| 581 | CAutoWipeBuffer buf; |
| 582 | if ( !CCrypto::DecodePEMBody( pBuffer, (uint32)cBytes, buf, "OPENSSH PRIVATE KEY" ) ) |
| 583 | return false; |
| 584 | uint8 privateThenPublic[64]; |
| 585 | if ( !BParseOpenSSHBinaryEd25519Private( buf, privateThenPublic ) ) |
| 586 | return false; |
| 587 | |
| 588 | if ( !SetRawDataAndWipeInput( privateThenPublic, 32 ) ) |
| 589 | return false; |
| 590 | |
| 591 | // Check that the public key matches the private one. |
| 592 | // (And also that all of our code works.) |
| 593 | if ( V_memcmp( m_publicKey, privateThenPublic+32, 32 ) == 0 ) |
| 594 | return true; |
| 595 | |
| 596 | AssertMsg( false, "Ed25519 key public doesn't match private!" ); |
| 597 | Wipe(); |
| 598 | return false; |
| 599 | } |
| 600 | |
| 601 | //----------------------------------------------------------------------------- |
| 602 | // CECSigningPublicKey |