| 2403 | } |
| 2404 | |
| 2405 | private List<KeyScheduleEpoch.PSKWithSecret> resolve(List<PreSharedKeyID> psks) |
| 2406 | throws Exception |
| 2407 | { |
| 2408 | List<KeyScheduleEpoch.PSKWithSecret> out = new ArrayList<KeyScheduleEpoch.PSKWithSecret>(); |
| 2409 | for (PreSharedKeyID psk : psks) |
| 2410 | { |
| 2411 | switch (psk.pskType) |
| 2412 | { |
| 2413 | case EXTERNAL: |
| 2414 | if (!externalPSKs.containsKey(psk.external.externalPSKID)) |
| 2415 | { |
| 2416 | throw new Exception("Unknown external PSK"); |
| 2417 | } |
| 2418 | out.add(new KeyScheduleEpoch.PSKWithSecret(psk, new Secret(externalPSKs.get(psk.external.externalPSKID).clone()))); |
| 2419 | break; |
| 2420 | case RESUMPTION: |
| 2421 | if (psk.resumption.pskEpoch == epoch) |
| 2422 | { |
| 2423 | out.add(new KeyScheduleEpoch.PSKWithSecret(psk, keySchedule.resumptionPSK)); |
| 2424 | } |
| 2425 | else |
| 2426 | { |
| 2427 | EpochRef key = new EpochRef(psk.resumption.pskGroupID, psk.resumption.pskEpoch); |
| 2428 | if (!resumptionPSKs.containsKey(key)) |
| 2429 | { |
| 2430 | throw new Exception("Unknown resumption PSK"); |
| 2431 | } |
| 2432 | out.add(new KeyScheduleEpoch.PSKWithSecret(psk, new Secret(resumptionPSKs.get(key).clone()))); |
| 2433 | } |
| 2434 | break; |
| 2435 | } |
| 2436 | } |
| 2437 | return out; |
| 2438 | } |
| 2439 | } |