I don't understand your comment so forgive me if this is off track.
Section 8 in the rfc outlines the math process for the exchange.
the preshared key is exchaged off line and manually added to both gateway nodes. During the negociation process as outlined the gateways verfify they both have the same value for the preshared key. and complete the tunnel setup process.
The reason for this method is to have a value for the encryption that never hits the wire and thus is never able to be seen by a third party.
Another alternative for this effect is to install matching certificates on the gateway instead.