(My strategy is quite wordy, but works as well.)
A=1 min, B=2 mins, C=7 mins, D= 10 mins
To get 17 minutes, first I thought of what wouldn't be possible. As C and D have a total time of 17 minutes, that means they shouldn't cross separately since more time will be required to go back for others. Therefore, they need to cross together. If C and D go first, one person needs to go back for the rest which will take at least 7 minutes, so they should not go first. With that information, that only leads me to believe A and B need to cross first. After they have crossed, I chose A to return the torch because he is quicker (although it does not matter because later on, the person who does not return now, will need to be the one to return later, adding to the same sum). At this point, only 3 minutes have passed. As I earlier mentioned, C and D need to go together so less time will be taken and this is the appropriate time for them since now we do not have the problem of taking an additional 7 minutes to cross now that B may return instead. So after C and D cross, as well as B after to return for A, the total time will be 15 minutes, and after A and B finally cross together, the total time will be 17 minutes, with everyone safe and happy on the other side!
For 21 minutes, you could simply use the fastest person (A) to carry the torch with everyone individually so he may efficiently return in 1 minute, and at the partner's pace.