mirror of
https://github.com/twofas/2fas-server.git
synced 2024-12-12 12:09:56 +01:00
24 lines
566 B
Go
24 lines
566 B
Go
|
package crypto
|
||
|
|
||
|
import (
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func Test_ConvertKeyPairToStringAndBackward(t *testing.T) {
|
||
|
keyPair := GenerateKeyPair(2048)
|
||
|
|
||
|
privateKeyAsPemStr := ExportRsaPrivateKeyAsPemStr(keyPair.PrivateKey)
|
||
|
publicKeyAsPemStr := ExportRsaPublicKeyAsPemStr(keyPair.PublicKey)
|
||
|
|
||
|
assert.NotEmpty(t, publicKeyAsPemStr)
|
||
|
|
||
|
_, err := ParseRsaPrivateKeyFromPemStr(privateKeyAsPemStr)
|
||
|
|
||
|
assert.NoError(t, err, "Cannot convert PEM string to private key")
|
||
|
|
||
|
_, err = ParseRsaPublicKeyFromPemStr(publicKeyAsPemStr)
|
||
|
|
||
|
assert.NoError(t, err)
|
||
|
}
|